简体   繁体   English

如何使cURL脚本更安全?

[英]what could I do to make my cURL script more secure?

Ok, guys, I've been thinking and thinking and thinking, and now finally out of ideas... 好的,伙计们,我一直在思考,思考,思考,现在终于摆脱了主意...

So I've devolped this WordPress plugin, that takes customers info from a SQL DB on my server, through cURL. 因此,我开发了这个WordPress插件,该插件通过cURL从服务器上的SQL DB获取客户信息。

So this is what happens: 这就是发生的情况:

Each user that downloads the plugin from my site has a unique ID which is generated from Mysql (auto_increment). 从我的网站下载插件的每个用户都有一个唯一的ID,该ID是从Mysql(auto_increment)生成的。 This ID is stored in the plugin on download. 此ID在下载时存储在插件中。 The plugin then uses this ID to select a row and take some info (sensetive info) in my db on my server, using cURL. 然后,插件使用该ID来选择一行,并使用cURL在服务器上的数据库中获取一些信息(有意义的信息)。

So, here's how it fetches the info: 因此,这是它获取信息的方式:

1.) The unique ID is $_POST 'ed to the target page (my_curl.php) 1.)唯一ID是$_POST _POST'ed到目标页面(my_curl.php)

2.) A preg_match is ran on the posted ID to help prevent any silly SQL injections. 2.)在发布的ID上运行preg_match,以帮助防止任何愚蠢的SQL注入。

3.) The row is selected and the info is fetched. 3.)选择该行并获取信息。

4.) The info fetched from the DB gets JSON ENCODE. 4.)从数据库中获取的信息将获取JSON ENCODE。

Now anyone can just go in to the plugins files, and do this: 现在,任何人都可以进入插件文件,并执行以下操作:

if their copy of the plugin was assigned to the id: 21645875457 如果他们的插件副本已分配给ID:21645875457

they go in and change that id to one up or down: 21645875458 or 21645875456. 他们进入并将该ID更改为一个或多个:21645875458或21645875456。

they then run the plugin, and they see someone elses sensetive info.... 然后他们运行插件,然后看到其他人的感性信息...。

Can anybody come up with a few suggestions, to prevent this. 任何人都可以提出一些建议,以防止这种情况。 I know its close to impossible, but there's got to be something, right? 我知道它几乎是不可能的,但是必须有一些东西,对不对?

If i send some more info from the plugin to the curl target, the evil moster could just simply change that. 如果我将更多信息从插件发送到curl目标,那么最邪恶的人可能只是简单地更改了它。

Another peice of info that is in the DB is the domain the plugin is assigned to. 数据库中的另一个信息是插件分配到的域。

I was thinking of posting the current domain ( $_SERVER['HTTP_HOST'] ) to the cURL page and have it verified with the ID (check if the domain is in the same row as the ID). 我正在考虑将当前域( $_SERVER['HTTP_HOST'] )发布到cURL页面,并用ID进行验证(检查域是否与ID在同一行)。

That would make it harder for the attacker as they will need to know the ID AND the domain they want to steal the info from but i need something more secure... 这将使攻击者更难,因为他们将需要知道他们想要从中窃取信息的ID和域,但是我需要更安全的东西...

You could generate 'password' (in other words, random string) and store it in directory of plugin. 您可以生成“密码”(换句话说,随机字符串)并将其存储在插件目录中。 Also, save the 'password' into your database. 另外,将“密码”保存到数据库中。 Now, whenever someone wants to access any sensetive data - he need to provide not only the ID, but also the password. 现在,每当有人想要访问任何敏感数据时,他不仅需要提供ID,还需要提供密码。 They must match, obviously. 很明显,它们必须匹配。 (: (:

增加 ID到信息的映射(或您建议的ID和主机到客户的映射)的一种简便方法是使用顺序ID,而是分配更复杂的内容,例如,生成的UUID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM