Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL注入 #1

Closed
tongyifan opened this issue Jan 5, 2021 · 9 comments
Closed

SQL注入 #1

tongyifan opened this issue Jan 5, 2021 · 9 comments

Comments

@tongyifan
Copy link

NexusPHP中的 0 + $_GET[] 是为了令传入的必须是数字,以此防止SQL注入

而在此版本中将其改为了 $_GET[] ?? 0,存在注入问题。

@tongyifan
Copy link
Author

@Rhilip
Copy link

Rhilip commented Jan 5, 2021

(玩家3和玩家5已经完成注入测试了🤣🤣🤣🤣

@Rhilip
Copy link

Rhilip commented Jan 5, 2021

其实改成 filter_input(INPUT_GET, xxx, FILTER_VALIDATE_INT, ['options' => ['default' => 0]]) 会好些,不过还是建议上STMT哦

@xiaomlove
Copy link
Owner

楼上两位会玩,我忽略了 "0 +" 其实是在做类型转换。 @tongyifan 发送者不是本人这个问题是怎么弄出来的?

@xiaomlove
Copy link
Owner

其实改成 filter_input(INPUT_GET, xxx, FILTER_VALIDATE_INT, ['options' => ['default' => 0]]) 会好些,不过还是建议上STMT哦

这个没法上吧,都是大量的拼好的 sql 语句

@Rhilip
Copy link

Rhilip commented Jan 5, 2021

楼上两位会玩,我忽略了 "0 +" 其实是在做类型转换。 @tongyifan 发送者不是本人这个问题是怎么弄出来的?

你把 0+$_GET[] 改了,就留下注入漏洞了。
然后就可以拿到数据库users表的passhash字段,顺利登录你的账号了呗

image

其实改成 filter_input(INPUT_GET, xxx, FILTER_VALIDATE_INT, ['options' => ['default' => 0]]) 会好些,不过还是建议上STMT哦

这个没法上吧,都是大量的拼好的 sql 语句

OurBits这边,数据库这边90%以上语句都是STMT预处理了。

@xiaomlove
Copy link
Owner

楼上两位会玩,我忽略了 "0 +" 其实是在做类型转换。 @tongyifan 发送者不是本人这个问题是怎么弄出来的?

你把 0+$_GET[] 改了,就留下注入漏洞了。

然后就可以拿到数据库users表的passhash字段,顺利登录你的账号了呗

image

其实改成 filter_input(INPUT_GET, xxx, FILTER_VALIDATE_INT, ['options' => ['default' => 0]]) 会好些,不过还是建议上STMT哦

这个没法上吧,都是大量的拼好的 sql 语句

OurBits这边,数据库这边90%以上语句都是STMT预处理了。

还是不太懂。
1,通过哪个URL什么请求参数得到passhash。
2,这个字段单向加密得到,没什么用吧。登录需要原始密码啊。请大佬指点。

@Rhilip
Copy link

Rhilip commented Jan 5, 2021

  1. 请看你commit history,反正你修改过的地方都有可能有注入风险,我和杯具只利用了其中某一个。
  2. 对NPHP,只要有passhash和id对应,就可以改cookies变id了。请阅读 user_login() 签名方法以及 takelogin.php 实现。这也是部分站点修改cookie的原因。

不再回答了。

@xiaomlove
Copy link
Owner

感谢 @tongyifan @Rhilip
在保证不报错误的前提下,使用 intval() 恢复了原来 0+ 的强制类型转换。
本人对 NP 不了解,不知道有了 passhash 可以随意伪造用户 ID 的事,经实践确实是可以的。
但不恢复强制类型转换时哪些地方可能造成 passhash 泄露,还是不太清楚。现修改后不会再泄露了吧🤣

xiaomlove pushed a commit that referenced this issue May 23, 2023
修改初始下载推荐客户端为开源的 qbittorrent transmission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants