**如下:
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import string
import re
#需要提交post的url
target_url = ""
# 設定乙個cookie處理器
# 通過正則匹配抓到需要統計的字串
content = res.read()
check_text = re.findall(r'(.*)',content,re.s)[0]
# 簡單的統計
char_count = [0,0,0,0,0]
for txt in check_text:
if txt == 'w':
char_count[0] += 1
elif txt == 'o':
char_count[1] += 1
elif txt == 'l':
char_count[2] += 1
elif txt == 'd':
char_count[3] += 1
elif txt == 'y':
char_count[4] += 1
#將數字轉換成字串
result = ""
for nindex in char_count:
result += str(nindex)
print "result = ", result
# 接下來就是提交了
value =
data = urllib.urlencode(value)
request = urllib2.request(target_url,data)
response = opener.open(request)
html = response.read()
print html
需要注意的地方:你需要儲存下來第一次正則匹配時開啟頁面cookie,構造乙個opener,在第二次提交時使用之前的cookie即可。。。否則會提示超時
下面是乙個大牛給我的**,用到了第三方庫mechanize:
# coding=utf-8
import re
import urllib2
import mechanize
target_url = ""
# get target text use regular expression.
def get_text(content):
return re.findall(r'(.*)', content,re.s)[0]
def submit():
char_count = [0, 0, 0, 0, 0]
br_controller = mechanize.browser()
br_controller.set_handle_equiv(true)
br_controller.set_handle_redirect(true)
br_controller.set_handle_referer(true)
br_controller.set_handle_robots(false)
br_controller.addheaders = [("user-agent", user_agent)]
br_controller.open(target_url)
# get web page cotent
page_content = br_controller.response().read()
# get target text
check_text = get_text(page_content)
# calculate
for txt in check_text:
if txt == 'w':
char_count[0] += 1
elif txt == 'o':
char_count[1] += 1
elif txt == 'l':
char_count[2] += 1
elif txt == 'd':
char_count[3] += 1
elif txt == 'y':
char_count[4] += 1
# change value in char_count to string.
result = ""
for nindex in char_count:
result += str(nindex)
print "result = ", result
# post form.
br_controller.select_form(nr=0)
br_controller.form['anwser'] = result
br_controller.submit()
print br_controller.response().read()
if __name__ == '__main__':
submit()
idf實驗室聰明的小羊
乙隻小羊跳過了柵欄,兩隻小樣跳過了柵欄,一坨小羊跳過了柵欄.tn c0afsiwal kes,hwit1r g,npt ttessfu ua u hmqik e m,n huiouosarwcniibecesnren.相信大家看到這題都會有點懵逼,不知道從何下手,看上去就是一堆亂亂的字元,但是出題人...
IDF實驗室 天羅地網 古老的郵件編碼
ctf.idf.cn index.php?g game m article a index id 41 題目 mr,o knyu q p q ahzs6q g,lknynz.lr 2lk n ck vn mxk tjj rkzaq 36k ch m xq 3pl b s 1 v t9gmu 75u ...
IDF實驗室之不難不易的js加密
開啟我們看到彈框讓我們輸flag,直接看到原始碼,我們看到 eval function p,a,c,k,e,d if replace string e function c 1 while c if k c p p.replace new regexp b e c b g k c return p ...