国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

alexCTF sock題目

2019-11-11 06:11:28
字體:
來源:轉載
供稿:網友

alex CTF 一道題目的半解過程

nc 連接返回結果

__________ ______/ ________ /______ _/ ____________ /_ _/____________ ____________/_/ ___________ / / ___________ /

/ /XXXXXXXXXXX/ // /XXXXXXXXXXX/ / / /############/ ############/ / | /XXXXXXXXXXX/ _ _ /XXXXXXXXXXX/ | |___ _ // / /|__ [_ / / X X / / _] | / / / / | [_ / / / _____ / / / __] / / / //||.||.||.||.||// / / / _ / / ||.||.||.||.|| / / _/ / / ||.||.||.||.|| / / _ |||||||||| _/ / …….. / ________________/

Our system system has detected human traffic from your ip! Please PRove you are a bot Question 1 : 108105798751584311773236747225139 - 35165179661324135973895883980449 =

利用程序來返回結果

思路:將nc反彈結果寫在記事本里,然后找到 =所在行,以及兩個數字(題目中的一個數字在兩行里),將計算結果發送給服務器端,然后再打印flag。 遇到一個很奇怪的事情:- -! 當對一個字符串進行查找判斷后再進行分割就找不到字符了

import socketimport resock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)sock.connect(('195.154.53.62',1337))filename='nc.txt'y=''res=''test=''while True: m=sock.recv(100) test=test+m print len(m) if len(m)<60: breakf=open(filename,'a')f.write(test)f.close()f=open(filename,'r')lines=f.readlines()for line in lines: if line.find(":"): try: x,y=line.split(":/n") except: pass if line.count('=')==1: try: line=line.replace('=/n','') line=line.replace(' ', '') line=line.replace('=','') if line.find('+')!=-1: print line.split('+'),'1' a=line.split('+')[0] b=line.split('+')[1] a=y+a res=int(a)+int(b) if line.find('-')!=-1: print line.split('-'),'2' a = line.split('-')[0] b= line.split('-')[1] a=y+a res =int(a) -int(b) if line.find('*')!=-1: print line.split('*'),'3' a = line.split('*')[0] b= line.split('*')[1] a=y+a res = int(a) *int(b) if line.find('/')!=-1: print line.split('/'),'4' a = line.split('/')[0] b= line.split('/')[1] a=y+a res = int(a) / int(b) if line.find('%')!=-1: print line.split('%'),'5' a = line.split('%')[0] b= line.split('%')[1] a=y+a res = int(a) % int(b) print 'asd',a print 'res',res sock.send(str(res)) print sock.recv(2048) print line except Exception, e: print esock.send(str(res))print sock.recv(100)f.close()

參考 大牛的 writeup http://www.cnblogs.com/huangjacky/p/3859786.html

找到一位日本友人的代碼,只能說明個人能力太渣 http://kataware.hatenablog.jp/

import socket,telnetlibimport math# common funcs ---def sock(remoteip, remoteport): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((remoteip,remoteport)) return s, s.makefile('rw',bufsize=0)def read_until(f,delim='/n'): data = '' while not data.endswith(delim): data+= f.read(1) return datadef ans(): r= '' # Questionの文字まで読み込む while "Question" not in r: r += f.read(1) print(r) r = '' # Question番號まで読み込む while "/n" not in r: r += f.read(1) print(r) r = '' first = '' second = '' r = read_until(f) print(r) # 問題を読み込む lis = r.split(' ') first = long(lis[0]) ope = lis[1] second = long(lis[2]) # math if ope == "+": ret = int(first + second) elif ope == "-": ret = int(first - second) elif ope== "*": ret = first * second elif ope== "/": ret = math.floor(first/second) elif ope== "%": ret = int(first % second) if ret == int(ret): ret = int(ret) f.write(ret) f.write("/n") print(str(ret)+"/n")# mains, f = sock('195.154.53.62', 1337)r = ''for i in range(10000): ans()
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丰都县| 昭觉县| 大竹县| 湘乡市| 上犹县| 多伦县| 长寿区| 灵宝市| 抚宁县| 石景山区| 镇康县| 沅江市| 湘乡市| 龙泉市| 富阳市| 衢州市| 句容市| 咸阳市| 来安县| 白水县| 泽库县| 嘉定区| 临夏县| 杭州市| 高密市| 平邑县| 临朐县| 永春县| 迁西县| 琼中| 荃湾区| 景洪市| 社旗县| 邳州市| 黑水县| 沁水县| 平乐县| 万盛区| 文登市| 乐安县| 凤翔县|