Protostar net2
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,This level is at /opt/protostar/bin/net2Source code#include "../common/common.c"#define NAME "net2"#
千家信息网最后更新 2025年02月01日Protostar net2This level is at /opt/protostar/bin/net2
This level is at /opt/protostar/bin/net2Source code
#include "../common/common.c"
#define NAME "net2"
#define UID 997
#define GID 997
#define PORT 2997
void run()
{
unsigned int quad[4];
int i;
unsigned int result, wanted;
result = 0;
for(i = 0; i < 4; i++) {
quad[i] = random();
result += quad[i];
if(write(0, &(quad[i]), sizeof(result)) != sizeof(result)) {
errx(1, ":(\n");
}
}
if(read(0, &wanted, sizeof(result)) != sizeof(result)) {
errx(1, ":<\n");
}
if(result == wanted) {
printf("you added them correctly\n");
} else {
printf("sorry, try again. invalid\n");
}
}
int main(int argc, char **argv, char **envp)
{
int fd;
char *username;
/* Run the process as a daemon */
background_process(NAME, UID, GID);
/* Wait for socket activity and return */
fd = serve_forever(PORT);
/* Set the client socket to STDIN, STDOUT, and STDERR */
set_io(fd);
/* Don't do this :> */
srandom(time(NULL));
run();
}
这题也是从上一题延伸过来,通过分析题目可以得到程序通过一个for循环生成4个随机数,分4次大小以sizeof(result)发送,用另一个变量来保存4个变量相加的和,如果客户端返回四个数的和相等的数即可。
#!/usr/bin/env python
from socket import *
from struct import *
from optparse import OptionParser
def main(hostname,port):
s = socket(AF_INET,SOCK_STREAM)
s.connect((hostname,port))
result = 0
for i in range(4):
rec = s.recv(4)
num = unpack("print "num[%d]:%d"%(i,num)
result += num
print str(result)
s.send(pack("print s.recv(1024)
s.close()
if __name__=="__main__":
parse = OptionParser("usage: %prog [options]")
parse.add_option("-H",dest="hostname",default="127.0.0.1",type="string",help="The ip of the target")
parse.add_option("-P",dest="port",default=2997,type="int",help="The port of the host")
(options,args)=parse.parse_args()
main(options.hostname,options.port)
运行结果:D:\Python27\a\protostar>debug.py -H 192.168.0.71
num[0]:605764919
num[1]:1932937542
num[2]:278220490
num[3]:835448954
3652371905
you added them correctly
变量
个数
大小
客户
客户端
程序
结果
随机数
题目
上一
分析
循环
生成
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
买一台编程软件开发的手提电脑
时间格式写入数据库int
怎么查询浏览器代理服务器
宜兴多功能软件开发产品介绍
冒险岛数据库详解
网络安全协议有什么
如何查看主机数据库的各种信息
软件开发的前期工作
商业软件开发模型
戴尔pc服务器管理口账号
数据库服务器没有成功启动
红梦网络安全工作室
菲律宾服务器模式
数据库安装和下载
ota网络安全
汇丰软件开发职级
数据库三个主要组件
网络安全中央财经
做安卓软件开发容易吗
渝中区一站式网络技术协议
电影讲没有绝对的网络安全
外网ip无法连接数据库
联运服务器是什么意思
数据库系统要怎么样才安全
广州花开网络技术公司
比较数据库结构
公安部科技信息化局服务器
2021年服务器市场规模
怎样退出吱呀服务器
核酸表数据库