精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網站建設資訊

NEWS

網站建設資訊

Protostarnet1

This level is at /opt/protostar/bin/net1

Source 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









網頁名稱:Protostarnet1
文章出自:http://m.jcarcd.cn/article/jgsjsd.html
主站蜘蛛池模板: 国产激情片 | 91国产精品 | 三级特黄60分 | 日韩欧美激情刺激 | 日本高清三区 | 国产h精品在线观看 | 国精品一区二 | 国产黄在线视频免费 | 91香蕉影院| 欧美综合在线观看 | 动漫一区 | 91最新在线观看 | 人妖系列精品视频 | 日本亲子乱在线播放 | 精品区在线观看 | 国产视频综合 | 乱伦国产欧美三级 | 91午夜成人影院 | 精品女性丯国产 | 日本aⅴ深 | 91成人小视频 | 精品福利导航 | 国产高清成免费视频 | 国产成年人视频免费 | 国产精品1234区 | 乱伦国产影视欧美 | 国产全黄三级播放 | 日韩a一级| 国产全黄三级播放 | 国产极品翘臀在线观 | 成人动漫一区 | 日韩高清在线二区 | 国产精品碰碰现在自 | 午夜免费时刻 | 国产午夜不卡一区 | 精品国产尤物 | 国产久热精品 | 日韩在线观看精品 | 女同另类激情重口 | 日本天堂免费观看 | 精品a视频在线观看 |