2021-05-25


整个操作,很无脑。
只要你够勤快,你学不会,你来咬我。
懒人和伸手党就直接复制代码去玩吧,但我不是叫你拿去干坏事。

准备工具:WPE和IE浏览器,WPE是一个比较不和谐的东西,我就不上传了,想学的人自己百度去下载一个,注意360要添加白名单。

你有什么好的拦截数据工具,你可以用你自己觉得习惯的东西,我选择用WPE,是因为我只会用WPE,各种复杂的工具对我来说,不如WPE直接让send与recv函数呈现数据那么直观。如果你们觉得WPE的操作太复杂了,学不会了,我只能和你说,少玩点国产游戏吧,你已经被毒害的不轻了。

好的,现在你可以一边看这个帖子,一边跟着动手。

1、关闭除了该帖子以外的浏览器,打开一个IE浏览器窗口,转到http://bbs.anjian.com/

2、如果你已经是登录状态,请点击“退出”按钮。

3、打开WPE,点击目标程序,选择IEXPLORE.EXE,你会发现有好多个IEPLORE.EXE,这个时候怎么办呢,一个个的尝试,怎么尝试呢,选择目标之后,点击像 播放 一样的三角形按钮 开始拦截,之后刷新 才打开的论坛的浏览器,如果此时,WPE上发现数据包有动静了,那么就说明我们要拦截封包的IE就是这个进程了,然后把WPE停止拦截掉。

操作如下图:选择进程
<ignore_js_op> 

点击三角形的这个拦截按钮进行测试:
<ignore_js_op> 

当接收到你刷新页面时,如果接收到数据包了,就说明这个进程就是我们需要拦截封包的进程了。然后我们先点击红色方块的停止拦截按钮,停止拦截,停止后WPE视图中会弹出一个数据包窗口,把它关掉,现在暂时不需要他。

<ignore_js_op> 

然后在把你的论坛帐号,密码输入好,但是不要点击登录,到WPE里,再次点击 拦截按钮,开始拦截以后,回到论坛页面,点击登录。回到WPE,点击停止拦截按钮。好了,关键的数据包就被我们抓到了。如下图所示,第一条是包头,第二条是你的帐号,密码,是否勾选了自动登录。
<ignore_js_op> 

我们把我们拦截到的内容复制出来先,如图所示,选择一条封包,把下面拉大点。选择右边的明文部分,拉到底,然后复制。出来粘贴到记事本里。 <ignore_js_op> 

 

  1.  
  2. 我复制出来的包头
  3. POST /member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1 HTTP/1.1..Accept: application/x-shockwave-flash, image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*..Referer: http://bbs.anjian.com/forum.php..Accept-Language: zh-cn..User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0C; .NET4.0E)..Content-Type: application/x-www-form-urlencoded..Accept-Encoding: gzip, deflate..Host: bbs.anjian.com..Content-Length: 80..Connection: Keep-Alive..Cache-Control: no-cache..Cookie: pgv_pvi=6736137576; Hm_lvt_98f3a9670f29a44a87e66a55ac40dda1=1329499272812; pgv_info=ssi=s1221392111; AJSTAT_ok_times=15; Hm_lvt_5d96b144d9b7632ed0ce359527dcc65d=1329511823453; AJSTAT_ok_pages=47; gUmJ_2132_widthauto=-1; gUmJ_2132_sid=sSshM7; gUmJ_2132_lastvisit=1329504510; gUmJ_2132_lastact=1329511820%09home.php%09misc; gUmJ_2132_connect_is_bind=1; gUmJ_2132_sendmail=1; Hm_lpvt_5d96b144d9b7632ed0ce359527dcc65d=1329511823
  4.  
  5. 这是帐号,密码,cookie时间,其他的都不用管。
  6. username=isaacc&cookietime=2592000&password=******&quickforward=yes&handlekey=ls

复制代码


现在,我们要开始写代码了。打开按键精灵。

首先把帐号,密码,cookie这些东西设置好。
username = "isaacc" '你的帐号
password = "******" '你的密码

buf = "username=" & username & "&cookietime=2592000&password=" & password & "&quickforward=yes&handlekey=ls"

创建目前最高版本的XMLHTTP对象。
Set http = CreateObject("Msxml2.ServerXMLHTTP.4.0")

然后注意看包头:

  1. /member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1

复制代码

这一段就是登录页面的地址,也就是,你鼠标指向登录按钮便可以看到状态栏上显示出来的东西。
所以,我们POST的地址为:
http.Open "POST", "http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1", False

然后我们要先取出论坛的Cookie设置,所以要先发送一次,把cookie设置取出来,留做登陆时设置cookie。
http.send buf
cookie = http.getResponseHeader("Set-Cookie") '获取Cookie设置

由于对象已经发送过一次了,要再次发送,需要重新设置POST地址。

http.open "POST", "http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1", False

那么,现在我们根据WPE拦截到的包头来进行设置POST的包头吧。

  1. Accept: application/x-shockwave-flash, image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*

复制代码

http.setRequestHeader "Accept", _
"application/x-shockwave-flash, " & _ 
"image/gif, image/jpeg, image/pjpeg, " & _
"application/x-ms-application, " & _ 
"application/x-ms-xbap, " & _ 
"application/vnd.ms-xpsdocument, " & _ 
"application/xaml+xml, */*"
'Accept表示我们所用的浏览器能接受的Content-type
 

  1. Referer: http://bbs.anjian.com/forum.php

复制代码

http.setRequestHeader "Referer", "http://bbs.anjian.com/forum.php" 'Referer表示当前页面是从那个页面链接来的
 

  1. Accept-Language: zh-cn

复制代码


http.setRequestHeader "Accept-Language", "zh-cn" '语言设置

然后的 User-Agent: 这一段不要管,这是你电脑上的信息。
 

  1. Content-Type: application/x-www-form-urlencoded

复制代码

http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 'Content-Type表示客户端提交给服务器文本内容的编码方式 

Accept-Encoding: 这一段也不用管,这是关于什么压缩的,反正不懂,直接无视它。
 

  1. Host: bbs.anjian.com

复制代码

http.setRequestHeader "Host", "bbs.anjian.com" 'Host表示提交请求的主机
 

  1. Content-Length: 80

复制代码

http.setRequestHeader "Content-Length", Len(buf) '表示提交的数据字节大小,也就是发送帐号密码这一条封包的长度。我们上面有一个buf变量,你不会忘了吧。
 

  1. Connection: Keep-Alive

复制代码

http.setRequestHeader "Connection", "Keep-Alive" '数据传递完并不立即关闭连接

 

  1. Cache-Control: no-cache

复制代码

http.setRequestHeader "Cache-Control", "no-cache" '返回消息中的Cache用于指定网页缓存



最后,设置Cookie头,利用我们第一次POST取出来的东西来设置。
http.setRequestHeader "Cookie", cookie

然后,恩。。发送。。
http.Send buf


最后我们把POST后的论坛源码取出来看看是否登录成功了,如果成功了,会显示你的积分等信息。
http.open "GET", "http://bbs.anjian.com/", False
Http.Send 
xmlBody = http.ResponseBody
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write xmlBody
.Position = 0
.Type = 2
.Charset = "GB2312"
BytesToBstr = .ReadText
.Close
End With

Call Plugin.Sys.SetCLB(BytesToBstr)
MsgBox "已将登陆后论坛的源文件放到剪切板,粘贴到记事本即可看到。"

 

Dim username, password, cookie, buf
username = "isaacc" '你的帐号
password = "******" '你的密码
buf = "username=" & username & "&cookietime=2592000&password=" & password & "&quickforward=yes&handlekey=ls"
Set http = CreateObject("Msxml2.ServerXMLHTTP.4.0")
http.open "POST", "http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1", False
http.send buf
cookie = http.getResponseHeader("Set-Cookie")'获取Cookie设置
 
http.open "POST", "http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1", False
http.setRequestHeader "Accept", _
"application/x-shockwave-flash, " & _
"image/gif, image/jpeg, image/pjpeg, " & _
"application/x-ms-application, " & _
"application/x-ms-xbap, " & _
"application/vnd.ms-xpsdocument, " & _
"application/xaml+xml, */*"
'表示我们所用的浏览器能接受的Content-type
 
http.setRequestHeader "Referer", "http://bbs.anjian.com/forum.php" '当前页面是从那个页面链接来的
http.setRequestHeader "Accept-Language", "zh-cn" '语言设置
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" '表示客户端提交给服务器文本内容的编码方式
'http.setRequestHeader "Accept-Encoding", "gzip, deflate"
http.setRequestHeader "Host", "bbs.anjian.com" '所请求的主机
http.setRequestHeader "Content-Length", Len(buf) '表示提交的数据字节大小
http.setRequestHeader "Connection", "Keep-Alive" '数据传递完并不立即关闭连接
http.setRequestHeader "Cache-Control", "no-cache" '返回消息中的Cache用于指定网页缓存
http.setRequestHeader "Cookie", cookie
http.Send buf
 
http.open "GET", "http://bbs.anjian.com/", False
Http.Send
xmlBody = http.ResponseBody
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1//2-文本模式读取,1-二进制模式   
.Mode = 3  //3-读写,1-读,2-写
.Open
.Write xmlBody
.Position = 0
.Type = 2
.Charset = "GB2312"
BytesToBstr = .ReadText
.Close
End With
 
Call Plugin.Sys.SetCLB(BytesToBstr)



好了,完整的源码在下面:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

Dim username, password, cookie, buf

username = "isaacc" '你的帐号

password = "******" '你的密码

buf = "username=" & username & "&cookietime=2592000&password=" & password & "&quickforward=yes&handlekey=ls"

Set http = CreateObject("Msxml2.ServerXMLHTTP.4.0")

http.open "POST""http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1"False

http.send buf

cookie = http.getResponseHeader("Set-Cookie")'获取Cookie设置

 

http.open "POST""http://bbs.anjian.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1"False

http.setRequestHeader "Accept", _

"application/x-shockwave-flash, " & _

"image/gif, image/jpeg, image/pjpeg, " & _

"application/x-ms-application, " & _

"application/x-ms-xbap, " & _

"application/vnd.ms-xpsdocument, " & _

"application/xaml+xml, */*"

'表示我们所用的浏览器能接受的Content-type

 

http.setRequestHeader "Referer""http://bbs.anjian.com/forum.php" '当前页面是从那个页面链接来的

http.setRequestHeader "Accept-Language""zh-cn" '语言设置

http.setRequestHeader "Content-Type""application/x-www-form-urlencoded" '表示客户端提交给服务器文本内容的编码方式

'http.setRequestHeader "Accept-Encoding", "gzip, deflate"

http.setRequestHeader "Host""bbs.anjian.com" '所请求的主机

http.setRequestHeader "Content-Length", Len(buf) '表示提交的数据字节大小

http.setRequestHeader "Connection""Keep-Alive" '数据传递完并不立即关闭连接

http.setRequestHeader "Cache-Control""no-cache" '返回消息中的Cache用于指定网页缓存

http.setRequestHeader "Cookie", cookie

http.Send buf

 

http.open "GET""http://bbs.anjian.com/"False

Http.Send

xmlBody = http.ResponseBody

Set ObjStream = CreateObject("Adodb.Stream")

With ObjStream

.Type = 1//2-文本模式读取,1-二进制模式   

.Mode = 3  //3-读写,1-读,2-写

.Open

.Write xmlBody

.Position = 0

.Type = 2

.Charset = "GB2312"

BytesToBstr = .ReadText

.Close

End With

 

Call Plugin.Sys.SetCLB(BytesToBstr)

 

MsgBox "已将登陆后论坛的源文件放到剪切板,粘贴到记事本即可看到。"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
使用python中的pymsql完成如下:表结构与数据创建 1. 建立 `users` 表和 `orders` 表。 `users` 表有用户ID、用户名、年龄字段,(id,name,age) `orders` 表有订单ID、订单日期、订单金额,用户id字段。(id,order_date,amount,user_id) 2 两表的id作为主键,`orders` 表用户id为users的外键 3 插入数据 `users` (1, '张三', 18), (2, '李四', 20), (3, '王五', 22), (4, '赵六', 25), (5, '钱七', 28); `orders` (1, '2021-09-01', 500, 1), (2, '2021-09-02', 1000, 2), (3, '2021-09-03', 600, 3), (4, '2021-09-04', 800, 4), (5, '2021-09-05', 1500, 5), (6, '2021-09-06', 1200, 3), (7, '2021-09-07', 2000, 1), (8, '2021-09-08', 300, 2), (9, '2021-09-09', 700, 5), (10, '2021-09-10', 900, 4); 查询语句 1. 查询订单总金额 2. 查询所有用户的平均年龄,并将结果四舍五入保留两位小数。 3. 查询订单总数最多的用户的姓名和订单总数。 4. 查询所有不重复的年龄。 5. 查询订单日期在2021年9月1日至9月4日之间的订单总金额。 6. 查询年龄不大于25岁的用户的订单数量,并按照降序排序。 7. 查询订单总金额排名前3的用户的姓名和订单总金额。 8. 查询订单总金额最大的用户的姓名和订单总金额。 9. 查询订单总金额最小的用户的姓名和订单总金额。 10. 查询所有名字中含有“李”的用户,按照名字升序排序。 11. 查询所有年龄大于20岁的用户,按照年龄降序排序,并只显示前5条记录。 12. 查询每个用户的订单数量和订单总金额,并按照总金额降序排序。
最新发布
06-03
这里是使用 Python 的 PyMySQL 完成上述任务的代码: ```python import pymysql # 连接数据库 conn = pymysql.connect(host='localhost', port=3306, user='root', password='123456', database='test') # 创建游标 cur = conn.cursor() # 创建 users 表 cur.execute(''' CREATE TABLE users ( id INT PRIMARY KEY, name VARCHAR(20), age INT ) ''') # 创建 orders 表 cur.execute(''' CREATE TABLE orders ( id INT PRIMARY KEY, order_date DATE, amount INT, user_id INT, FOREIGN KEY (user_id) REFERENCES users(id) ) ''') # 插入数据 users_data = [ (1, '张三', 18), (2, '李四', 20), (3, '王五', 22), (4, '赵六', 25), (5, '钱七', 28) ] orders_data = [ (1, '2021-09-01', 500, 1), (2, '2021-09-02', 1000, 2), (3, '2021-09-03', 600, 3), (4, '2021-09-04', 800, 4), (5, '2021-09-05', 1500, 5), (6, '2021-09-06', 1200, 3), (7, '2021-09-07', 2000, 1), (8, '2021-09-08', 300, 2), (9, '2021-09-09', 700, 5), (10, '2021-09-10', 900, 4) ] for user in users_data: cur.execute('INSERT INTO users VALUES (%s, %s, %s)', user) for order in orders_data: cur.execute('INSERT INTO orders VALUES (%s, %s, %s, %s)', order) # 提交事务 conn.commit() # 查询语句 # 1. 查询订单总金额 cur.execute('SELECT SUM(amount) FROM orders') print(cur.fetchone()[0]) # 2. 查询所有用户的平均年龄,并将结果四舍五入保留两位小数。 cur.execute('SELECT ROUND(AVG(age), 2) FROM users') print(cur.fetchone()[0]) # 3. 查询订单总数最多的用户的姓名和订单总数。 cur.execute(''' SELECT users.name, COUNT(*) AS total_orders FROM users JOIN orders ON users.id = orders.user_id GROUP BY users.id ORDER BY total_orders DESC LIMIT 1 ''') print(cur.fetchone()) # 4. 查询所有不重复的年龄。 cur.execute('SELECT DISTINCT age FROM users') print([row[0] for row in cur.fetchall()]) # 5. 查询订单日期在2021年9月1日至9月4日之间的订单总金额。 cur.execute('SELECT SUM(amount) FROM orders WHERE order_date BETWEEN "2021-09-01" AND "2021-09-04"') print(cur.fetchone()[0]) # 6. 查询年龄不大于25岁的用户的订单数量,并按照降序排序。 cur.execute(''' SELECT users.name, COUNT(*) AS total_orders FROM users JOIN orders ON users.id = orders.user_id WHERE age <= 25 GROUP BY users.id ORDER BY total_orders DESC ''') print(cur.fetchall()) # 7. 查询订单总金额排名前3的用户的姓名和订单总金额。 cur.execute(''' SELECT users.name, SUM(amount) AS total_amount FROM users JOIN orders ON users.id = orders.user_id GROUP BY users.id ORDER BY total_amount DESC LIMIT 3 ''') print(cur.fetchall()) # 8. 查询订单总金额最大的用户的姓名和订单总金额。 cur.execute(''' SELECT users.name, SUM(amount) AS total_amount FROM users JOIN orders ON users.id = orders.user_id GROUP BY users.id ORDER BY total_amount DESC LIMIT 1 ''') print(cur.fetchone()) # 9. 查询订单总金额最小的用户的姓名和订单总金额。 cur.execute(''' SELECT users.name, SUM(amount) AS total_amount FROM users JOIN orders ON users.id = orders.user_id GROUP BY users.id ORDER BY total_amount ASC LIMIT 1 ''') print(cur.fetchone()) # 10. 查询所有名字中含有“李”的用户,按照名字升序排序。 cur.execute('SELECT * FROM users WHERE name LIKE "%李%" ORDER BY name ASC') print(cur.fetchall()) # 11. 查询所有年龄大于20岁的用户,按照年龄降序排序,并只显示前5条记录。 cur.execute('SELECT * FROM users WHERE age > 20 ORDER BY age DESC LIMIT 5') print(cur.fetchall()) # 12. 查询每个用户的订单数量和订单总金额,并按照总金额降序排序。 cur.execute(''' SELECT users.name, COUNT(*) AS total_orders, SUM(amount) AS total_amount FROM users JOIN orders ON users.id = orders.user_id GROUP BY users.id ORDER BY total_amount DESC ''') print(cur.fetchall()) # 关闭游标和连接 cur.close() conn.close() ``` 注意:在运行代码之前,需要先安装 PyMySQL 模块,可以使用以下命令进行安装: ``` pip install pymysql ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lst0426

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值