Protostar net1
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,This level is at /opt/protostar/bin/net1Source code#include "../common/common.c"#define NAME "net1"#
千家信息网最后更新 2025年12月02日Protostar net1This level is at /opt/protostar/bin/net1
This level is at /opt/protostar/bin/net1Source code
#include "../common/common.c"
#define NAME "net1"
#define UID 998
#define GID 998
#define PORT 2998
void run()
{
char buf[12];
char fub[12];
char *q;
unsigned int wanted;
wanted = random();
sprintf(fub, "%d", wanted);
if(write(0, &wanted, sizeof(wanted)) != sizeof(wanted)) {
errx(1, ":(\n");
}
if(fgets(buf, sizeof(buf)-1, stdin) == NULL) {
errx(1, ":(\n");
}
q = strchr(buf, '\r'); if(q) *q = 0;
q = strchr(buf, '\n'); if(q) *q = 0;
if(strcmp(fub, buf) == 0) {
printf("you correctly sent the data\n");
} else {
printf("you didn't send the data properly\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();
}
这题与上一题其实差不多,上一题是直接将字符串格式的输出,而这道题是以%d出输出。如果在客户端接收到这个%d数字直接输出的话肯定会出现乱码的,因此需要在客户端转化后再输出即可。直接上代码:
#!/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))
rec = s.recv(1024)
num = unpack("print str(num[0])
buf = num[0]
s.send(str(buf))
print s.recv(1024)
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=2998,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
1436569335
you correctly sent the data
输出
客户
上一
差不多
乱码
代码
字符
字符串
客户端
数字
格式
结果
肯定
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发技术学习方法
优企动力app软件开发
云南校驿网络技术有限公司
网络安全主动威胁包括哪些
山东创新服务器
APP的软件开发计划书
网络技术和计算机网络的区别
数据库执行过程命令
服务器 日志收集
河南新乡服务器托管云主机
服务器复制文件到容器里
网络安全的5个方面
大华服务器其中一台设备经常掉线
南昌软件开发怎么样
腾讯云电脑上怎么备份数据库
数据库实验二电子版表格
网络安全部门的工作总结
麻将软件开发工期
世界各国网络安全现状
人为制造数据库故障
我的世界贝爷生存服务器怎么开
软件开发合同标的内容怎么填
连接国内的vpn服务器
日本中学生网络安全
泰安app定制软件开发推荐
项目连接远程数据库不通
公司网络安全小组组长
c 随机double数据库
服务器电源的设计与维护
做软件开发甲方不给钱