Skip to content

Instantly share code, notes, and snippets.

@cryptid11
Last active November 16, 2019 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryptid11/9528debcaa674a87abec82e39631f88a to your computer and use it in GitHub Desktop.
Save cryptid11/9528debcaa674a87abec82e39631f88a to your computer and use it in GitHub Desktop.
run asm via sh
alias escape="python -c $'import sys; a = sys.stdin; f = a.readlines()[0].strip(); print 2*'\''\\\\'\''+'\''x'\''+(2*'\''\\\\'\''+'\''x'\'').join([f[x:x+2] for x in range(len(f))][0::2])'"
alias a2e='echo -e "#include <stdio.h>\n#include <string.h>\nunsigned char shellcode[]=\"$(</dev/stdin)\";\nint main(){__asm__(\"call shellcode\");}" | gcc -m32 -fno-stack-protector -z execstack -o elf -xc -'
alias ee='python -c "from pwn import *; print asm(shellcraft.i386.linux.echo(\"$(</dev/stdin)\")+shellcraft.i386.linux.exit(), arch=\"i386\").encode(\"hex\")"'
alias ea2e='escape|a2e'
alias ea2ee='escape|a2e;./elf'
x () { echo $1 | ea2ee ;}
alias e=x
sudo apt update && sudo apt install -y build-essential libevent-dev gcc-multilib
sudo apt update && sudo apt-get install -y python2.7 python-pip python-dev git libssl-dev libffi-dev build-essential && sudo pip install --upgrade pwntools #for asm echo encoding
wget https://gist.githubusercontent.com/cryptid11/9528debcaa674a87abec82e39631f88a/raw/a2e -O ->> ~/.bashrc; source ~/.bashrc
examples:
echo 68010101018134246e2001016848656c6c6a04586a015b89e16a065acd8031db6a0158cd80|escape|a2e; ./elf
echo 68010101018134246e2001016848656c6c6a04586a015b89e16a065acd8031db6a0158cd80|ea2e; ./elf
echo 6a68682f2f2f73682f62696e89e368010101018134247269010131c9516a045901e15189e131d26a0b58cd80|ea2ee #scsh
shellcraft i386.linux.sh|ea2ee
e 31c9f7e1b00b51682f2f7368682f62696e89e3cd80 #scsh2
e 6801010101813424696e6f01682f707974682f62696e682f75737289e331c931d26a0b58cd80 #ascpython
ctf:
echo hello|ee|ea2ee #ctf
n=7; echo 'CTF{XD}'|eval $(python -c "print 'ee|'*$n+'ee'") #generate super hard ctf
n=7; time echo 'CTF{XD}'|eval $(python -c "print 'ee|'*$n+'ee'")|eval $(python -c "print 'ea2ee|'*$n+'ea2ee'") #ctf generation and solution XD
wget --quiet https://pastebin.com/raw/Gsk77nwg -O - | eval $(python -c "print 'ea2ee|'*7+'ea2ee'") #ctf solution XD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment