Skip to content

Instantly share code, notes, and snippets.

View ozzi-'s full-sized avatar
🎯
On point

ozzi-

🎯
On point
View GitHub Profile
@ozzi-
ozzi- / a.bat
Created February 13, 2024 17:18
start taskmgr
@ozzi-
ozzi- / a.html
Created February 13, 2024 17:13
<input type="file" id="avatar" name="avatar" />
@ozzi-
ozzi- / a.js
Last active February 13, 2024 17:05
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run("cmd.exe /C start microsoft-edge:http://www.microsoft.com");
import java.util.Collections;
public class RingBuffer<T> {
int length;
int currentPos = 0;
int firstPos = 0;
int lastPos;
private T[] buffer;
@ozzi-
ozzi- / index.html
Last active May 21, 2021 09:44
JavaScript form submit timeout handling
<html>
Form being submitted
<!-- longresponse.phg will take 30 seconds to respons, in order to simulate a timeout -->
<form id="response" method="GET" action="https://oz-web.com/longresponse.php">
<input type="hidden" name="status" id="status" value="*empty*" />
</form>
<script>
const form = document.getElementById("response");
function handleFail(){
// replace this with whatever code you have to handle the timeout
@ozzi-
ozzi- / binaryDownload.js
Last active March 29, 2021 13:11
JS - Download a binary file via XHR then prompt the save file dialog
<html>
<a id="downloadBinaryLink"></a>
<script>
// file.php here serves as a pseudo API that returns a binary as octect stream (and according Access-Control-Allow-Origin header)
doBinaryDownload("http://oz-web.com/file.php", loadBinaryScriptEdit);
function loadBinaryScriptEdit(blob){
var dataUri = window.URL.createObjectURL(blob);
var anchor = document.getElementById("downloadBinaryLink");
anchor.setAttribute('href', dataUri);
anchor.setAttribute('download', "pingsender.exe");
@ozzi-
ozzi- / equivRedirectBash.sh
Created January 28, 2021 14:01
follow meta equiv redirect with bash and curl
equiv=$(curl $YOURURL -sS | grep -i "http-equiv")
shopt -s nocasematch
regexp='\<meta http-equiv=\"*refresh\"* content=\"*[0-9]*\"*;\s*url=([a-zA-Z0-9\/\.\?=#&.]*)'
path=""
if [[ $equiv =~ $regexp ]]; then
echo "${BASH_REMATCH[1]}"
# curl $YOURURL${BASH_REMATCH[1]}
else
echo "Could not parse equiv!"
exit 3
@ozzi-
ozzi- / JSON - Remove Trailing Comma
Created December 3, 2020 09:09
removes trailing commas in JSON strings
// Input:
// [
// {
// "f00" : "bar",
// "info" : "this comma to my right is wrong",
// },
// {
// "f00" : "bar",
// "info" : "the comma on the line below is wrong too!"
// },
@ozzi-
ozzi- / tlscheck.sh
Created October 30, 2020 16:52
check supported tls versions of a server by defining a minimum allowed version
#!/bin/bash
# tlscheck will check if a specified url supports the defined mimum tls version and higher
# this is helpful to ensure hardening (i.E. does my server support 1.2 and newer only?)
# exit codes above 9 will signalize the tls version check that failed (i.E. 11 = TLS 1.1)
# exit codes below 6 will signalize wrong syntax
# exit code 6 means could not connect at all
# ----------------------------------------------------------------------------------------
# https://github.com/ozzi-
@ozzi-
ozzi- / doubleEncodingUTF8.java
Created October 26, 2020 14:54
java method to fix double encoded UTF-8 strings
public static void main(String[] args) {
String input = "werewräüèö";
String result = fixDoubleUTF8Encoding(input);
System.out.println(result); // werewräüèö
input = "üäöé";
result = fixDoubleUTF8Encoding(input);
System.out.println(result); // üäöé
}