博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢!本文仅用于学习与交流,不得用于非法用途! 网址 Pwn类,[BJDCTF 2nd]snake2_dyn 使用ssh远程登录 打开是一个这样的界面,微信能够扫描出来sNaKes,输入密码之后是这样的
CTF-Pwn-[BJDCTF 2nd]snake2_dyn
CTP平台
题目
![CTF-Pwn-[BJDCTF 2nd]snake2dyn运维归子莫的博客-](https://img-blog.csdnimg.cn/20200506165851614.png)
思路
远程连接
ssh -p 28117 ctf@node3.buuoj.cn![CTF-Pwn-[BJDCTF 2nd]snake2dyn运维归子莫的博客-](https://img-blog.csdnimg.cn/20200506165851760.png)
![CTF-Pwn-[BJDCTF 2nd]snake2dyn运维归子莫的博客-](https://img-blog.csdnimg.cn/20200506165851979.png)
snake.c源代码
#include <stdio.h> #include <time.h> #include <malloc.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <sys/select.h> #include <sys/time.h> #include <termio.h> #include <string.h> #define high 20 #define wide 30 #define up 1 #define down 2 #define left 3 #define right 4 // void setIO(unsigned int flag) { // if(flag) // system("stty cbreak -echo"); // else // system("stty cooked echo"); // } void StringReplace(char *buf, char src, char dest){ char *p = buf; while(*p){ if(p[0]==src){ p[0]=dest; } p++; } } unsigned int score = 0; unsigned int Level = 1; unsigned int direction = 1; unsigned int IsEat=0; unsigned int FoodH=5,FoodW=10; char Name[0x100]; char flag[0x1000]; unsigned int flag_pos = 0; char Picture[high][wide]; typedef struct snake{ unsigned int x; unsigned int y; struct snake* next; }Node,*PSnake; PSnake Init() { printf("SnakeMake start!n"); unsigned int len=5; PSnake head=(PSnake)malloc(sizeof(Node)); if(head == NULL) printf("Snake head make failed!n"); head->x=wide/2; head->y=high/2+5; head->next=NULL; unsigned int i=0; for(;i<5;i++) { PSnake P=(PSnake)malloc(sizeof(Node)); if(P==NULL) { printf("Snake is dead!n"); break; } P->x=wide/2; P->y=high/2-i+4; P->next=head; head=P; } printf("Snake is alive!n"); return head; } PSnake Eat(unsigned int x,unsigned int y,PSnake snake) { PSnake p=(PSnake)malloc(sizeof(Node)); if(p==NULL) { printf("New head make failed!"); } p->x = x; p->y = y; p->next=snake; score += 1; return p; } void Walk(unsigned int x,unsigned int y,PSnake snake) { PSnake p=snake; unsigned int a,b, c=x, d=y; while(p!=NULL) { a=p->x; b=p->y; p->x = c; p->y = d; c=a; d=b; p=p->next; } } unsigned int Serch(unsigned int x,unsigned int y,PSnake snake) { PSnake q=snake->next; while(q!= NULL) { if( ( (q->x) == x ) && ( (q->y) == y ) ) return 1; q=q->next; } return 0; } void WriteSnake(PSnake snake) { PSnake p=snake; while(p != NULL) { Picture[p->y][p->x]=flag[flag_pos%1000]; p=p->next; } } void Paint(void) { unsigned int y=high,x=wide,i,j; for(i=0; i<y; i++) for(j=0; j<x; j++) Picture[i][j]=' '; } static unsigned int cnt=1; void Print(char* p,unsigned int score,unsigned int Lev) { unsigned int a=high,b=wide,i=0,j; printf("