pwnable.kr第二遍---coin1

>>>>>coin1
pwnable服务器端有pwn
因此可以调用remote工具
可以使用recvline等内容


remote()
ssh.connect_remote()
socket.connect
1.remote("HOST",PORT)可以直接连接Host,此时如果需要连接pwnable.kr
//remote(host, port, timeout=pwnlib.timeout.Timeout.default)
//connect_remote(host, port, timeout = Timeout.default) -> ssh_connecter
//Connects to a host through an SSH connection.
if pwnale.kr端:host="localhost" port=9007
if client端:host="pwnable.kr" port=9007
2.ssh.connect_remote()是通过ssh来建立一个remote连接
//Connects to a host through an SSH connection.
3.socket
#Base type used for tubes.remote and tubes.listen classes
#Creates a TCP or UDP-connection to a remote host. 
也就是说remote()建立的本质就是socket连接,不过是封装了socket,直接在上层remote(host,port)
而socket的话,需要建立套接字,socket(AF_INET,SOCK_STREAM)
然后在这个基础上connect(host,port)
------
综上,其实用remote()就够了
只是在哪里用会影响host参数而已


为什么Bufsize设置为1024?
recv()函数的接收过程:
如果recv接收到的缓冲区中的内容长度大于bufsize,那么需要调用多次recv把数据读完
#当剩下的数据大于1024时,继续收1024大小;当剩下的数据小于1024时,收剩下的大小并退出循环
如果recv接收到的缓冲区内容小于bufsize,那么只接收内容长度


recvline_endswith
recvline_startswith
recvline_endswith:不断接收直到某行endswith something;返回最后一行接收到的数据;如果超时之后还没有收到符合规则的行,那么返回''
recvline_startswith:不断接收直到某行startswith something;返回最后一行收到的数据;如果超时没有收到相应行,则返回''


在写脚本与服务器交互的过程中,要弄清楚服务器端每次发送的数据,从而精准对话


split()分离....


ifl=='':print r.recv()!!!!!
当没有收到startswith('N')的行只会返回''
此时接收缓冲区中已经拿到了flag,需要再次调用recv()函数从而输出flag
接着程序会在split()处出错并结束

猜你喜欢

转载自blog.csdn.net/lee_ham/article/details/79586363
今日推荐