Simple Certificate Creation Script

Introduction In pentests, you often need to create X.509 certificates (e.g. for TLS) or Certificate Authorities (CAs) to mimic secure environments during your tests. Manually generating these certificates with tools like openssl can be time-consuming and error-prone, especially when you’re in a hurry. Who remembers all these commands? Whether you’re setting up a fake webserver for data exchange, a proxy setup, a machine-in-the-middle (MITM) attack, testing secure connections, or creating your own CA chain, manually generate these certificates should not take much time. ...

02.05.2019 · 5 min · Emanuel Duss

Tool/Script to encode and decode base16 (Hex) data

Introduction The RFC 4648 (The Base16, Base32, and Base64 Data Encodings) defines different methods to encode binary data. Every Unix like system has the tool base64 installed to encode and decode data using the base64 alphabet. This alphabet includes the characters A-Z, a-z, 0-9, +, / for the data and = for padding. The base16 encoding scheme, better known as hex encoding, uses the alphabet 0-9 and A-F. This encoding is case-insensitive. The GNU coreutils do not include a base16 tool. I searched for a hex encoding and decoding tool with the same functionality as base64 without success. That’s why I wrote a script so I can use it to hex encode and decode binary data. Basically, it’s a wrapper around some Perl code. ...

11.03.2017 · 4 min · Emanuel Duss

Fix the photos taken by your Jolla phone (EXIF date/time, rename, rotate)

Introduction If you take a photo with your Jolla phone, the date and time is not saved in the EXIF data. I like to have these data stored in my pictures, so they can easy be renamed. I wrote a script to add the date and time to the EXIF data based on the timestamp on the filesystem. Script The script does the following: Add the EXIF timestamp according to the filesystem timestamp Renames the photo like YYYY-mm-dd_HH-MM-SS Rotates the photo correctly Here is the script: ...

25.08.2016 · 2 min · Emanuel Duss

Script um eigene IP Adressen anzuzeigen (myip)

Einführung Jedes mal, wenn ich meine IP Adresse wissen will, gebe ich bei einer Suchmaschine “my ip address” ein und klicke auf eines der Ergebnisse. Dies ist nicht sehr elegant. Auf einem Server ohne Browser ist dies gar nicht möglich. Deshalb habe ich ein Script geschrieben, welches mir meine IP Adressen (IPv4 und IPv6) anzeigt. Script Das Script sieht folgenermassen aus: #!/usr/bin/env bash #IPURL="https://icanhazip.com/ip" IPURL="https://motd.ch/ip.php" print_usage(){ cat << EOI Displays IP addresses of the current host used for internet connections. Usage: myip [options] Options: -6 Show only IPv6 addresses (public ip address by default). -4 Show only IPv4 addresses (public ip address by default). -h Show usage help. -l Show local insted of public addresses. -g Show geolocation (using geoiplookup). No options produces a more verbose output. EOI } check_dependencies(){ local FAIL=0 for tool in "$@" do if ! hash "$tool" &> /dev/null then echo "The tool $tool does not exist." FAIL=1 fi done if [[ "$FAIL" == 1 ]] then exit 1 fi } print_public_ipv4_address(){ echo "$(curl -s -4 -L $IPURL || echo "")" } print_public_ipv6_address(){ echo "$(curl -s -6 -L $IPURL || echo "")" } print_public_ipv4_geolocation(){ geoiplookup "$PUBLIC_IPV4_ADDRESS" | awk -F": " '{printf($2)}' } print_public_ipv6_geolocation(){ geoiplookup6 "$PUBLIC_IPV6_ADDRESS" | awk -F": " '{printf($2)}' } print_local_ipv4_address(){ echo "$(curl -s -4 -L --write-out %{local_ip} $IPURL -o /dev/null || echo "")" } print_local_ipv6_address(){ echo "$(curl -s -6 -L --write-out %{local_ip} $IPURL -o /dev/null || echo "")" } main(){ while getopts 46ghlv name do case "$name" in 4) flag_4=1 ;; 6) flag_6=1 ;; g) flag_g=1 ;; h) print_usage exit ;; l) flag_l=1 ;; ?) print_usage >&2 exit 2 ;; esac done if [[ -n $flag_l && -n $flag_4 ]] then print_local_ipv4_address fi if [[ -n $flag_l && -n $flag_6 ]] then print_local_ipv6_address fi if [[ -z $flag_l && -n $flag_4 ]] then print_public_ipv4_address fi if [[ -z $flag_l && -n $flag_6 ]] then print_public_ipv6_address fi if [[ -z $flag_l && -z $flag_4 && -z $flag_6 ]] then PUBLIC_IPV4_ADDRESS=$(print_public_ipv4_address) PUBLIC_IPV6_ADDRESS=$(print_public_ipv6_address) echo -e "Public IPv4 address: ${PUBLIC_IPV4_ADDRESS:--}" echo -e "Public IPv6 address: ${PUBLIC_IPV6_ADDRESS:--}" LOCAL_IPV4_ADDRESS=$(print_local_ipv4_address) LOCAL_IPV6_ADDRESS=$(print_local_ipv6_address) echo -e "Local IPv4 address: ${LOCAL_IPV4_ADDRESS:--}" echo -e "Local IPv6 address: ${LOCAL_IPV6_ADDRESS:--}" echo "" if [[ -n "$PUBLIC_IPV4_ADDRESS" && -n "$LOCAL_IPV4_ADDRESS" ]] then if [[ "$PUBLIC_IPV4_ADDRESS" != "$LOCAL_IPV4_ADDRESS" ]] then echo "IPv4: NAT" else echo "IPv4: No NAT" fi fi if [[ -n "$PUBLIC_IPV6_ADDRESS" && -n "$LOCAL_IPV6_ADDRESS" ]] then if [[ "$PUBLIC_IPV6_ADDRESS" != "$LOCAL_IPV6_ADDRESS" ]] then echo "IPv6: NAT" else echo "IPv6: No NAT" fi fi if [[ -n "$flag_g" ]] then check_dependencies geoiplookup geoiplookup6 if [[ -n "$PUBLIC_IPV4_ADDRESS" ]] then PUBLIC_IPV4_GEOLOCATION="$(print_public_ipv4_geolocation)" echo "Geolocation IPv4: $PUBLIC_IPV4_GEOLOCATION" fi if [[ -n "$PUBLIC_IPV6_ADDRESS" ]] then PUBLIC_IPV6_GEOLOCATION="$(print_public_ipv6_geolocation)" echo "Geolocation IPv6: $PUBLIC_IPV4_GEOLOCATION" fi fi fi } main "$@" Die aktuellste Version davon gibt es auf GitHub in meinem Scripts Repository: myip. ...

28.02.2016 · 4 min · Emanuel Duss

QR-Code Scanner für die Konsole

Für Mobiltelefone gibt es Barcode/QR-Code Scanner wie Sand am Meer. Für Linux auf dem Desktop jedoch nicht. Deshalb bastelte ich mir ein kleines Script, damit ich aus der Bash QR-Codes scannen kann. Das Script baut auf den Tools scrot und zbar auf. QR-Code Abfotografieren Mit maim kann man Screenshots machen. Entweder klickt man in ein Fenster oder man zieht (mit derm Schalter -s) ein Range auf, welcher man scannen will: ...

15.12.2014 · 1 min · Emanuel Duss
×