九零登录

[【通过】] rsync未授权访问验证以及目录获取工具 //支持密码

[复制链接]
发表于 2016-12-22 18:26:07 | 显示全部楼层 |阅读模式
usage: rsyncCheck.py 扫描ip文件 线程 密码(可空)
获取rsync服务目录 为内网渗透以及大批量rsync验证提供便利

[Python] 纯文本查看 复制代码
import commands
from multiprocessing.dummy import Pool as ThreadPool
from sys import argv
import os

def rsyncExec(ip):
	try:
		out = [ip]
		cmd = 'rsync '+ip+'::'
		(status,output) = commands.getstatusoutput('rsync '+ip+'::')
		if status == 0:
			model = output.split()
		else:
			model = '1'
		if model != '1':
			for x in model:
				(statusCheck,outputCheck) = commands.getstatusoutput('rsync '+ip+'::'+x+'/')
				if statusCheck == 0:
					out.append(x)
		if len(out) > 1:
			return out
	except Exception as e:
		raise e

def readText(txtpath):
	libs = []
	fp = open(txtpath,'r')
	while 1:
		line = fp.readline()
		if line:
			libs.append(line.strip())
		else:
			break
	fp.close()
	return libs

if __name__ == '__main__':
	try:
		filepath,threed_num,password = argv[1:]
	except:
		filepath,threed_num = argv[1:]
	try:
		if password:
			os.environ['RSYNC_PASSWORD']=str(password)
	except:
		print '...ganga'
	ips = readText(filepath)
	pool = ThreadPool(int(threed_num))
	results = pool.map(rsyncExec,ips)
	pool.close()
	pool.join()
	fp = open('rsyncOut.txt','w')
	ret =  [str for str in results if str not in ['', ' ', None]]
	new_ret = list(set(ret))
	new_ret.sort(key=ret.index)
	for x in new_ret:
		fp.write(x[0]+'    ')
		for i in x[1:]:
			fp.write(" '"+i+"'")
		fp.write('\n')
	fp.close


内网版:
usage: rsyncCheck.py 扫描ip 线程 密码(可空)
把文件那块换成了直接生成ip段 扫描ip直接写c段最后不要加点
例如:192.168.1

[Python] 纯文本查看 复制代码
import commands
from multiprocessing.dummy import Pool as ThreadPool
from sys import argv
import os

def rsyncExec(ip):
	try:
		out = [ip]
		cmd = 'rsync '+ip+'::'
		(status,output) = commands.getstatusoutput('rsync '+ip+'::')
		if status == 0:
			model = output.split()
		else:
			model = '1'
		if model != '1':
			for x in model:
				(statusCheck,outputCheck) = commands.getstatusoutput('rsync '+ip+'::'+x+'/')
				if statusCheck == 0:
					out.append(x)
		if len(out) > 1:
			return out
	except Exception as e:
		raise e

if __name__ == '__main__':
	try:
		ip,threed_num,password = argv[1:]
	except:
		ip,threed_num = argv[1:]
		password = 0
	if password != 0:
		os.environ['RSYNC_PASSWORD']=str(password)
	ips = [str(ip)+ '.' +str(x) for x in range(255)]
	pool = ThreadPool(int(threed_num))
	results = pool.map(rsyncExec,ips)
	pool.close()
	pool.join()
	fp = open('rsyncOut.txt','w')
	ret =  [str for str in results if str not in ['', ' ', None]]
	for x in ret:
		fp.write(x[0]+'    ')
		for i in x[1:]:
			fp.write(" '"+i+"'")
		fp.write('\n')
	fp.close

评分

参与人数 1酒票 +5 收起 理由
管理05 + 5 欢迎加入90!

查看全部评分

发表于 2016-12-22 19:25:17 | 显示全部楼层
下载了 不能用啊, 具体怎么配置?
发表于 2016-12-22 21:47:51 | 显示全部楼层

RE: rsync未授权访问验证以及目录获取工具 //支持密码

baidunew 发表于 2016-12-22 19:25
下载了 不能用啊, 具体怎么配置?

要系统装了rsync才行。
发表于 2016-12-23 13:29:27 | 显示全部楼层
需要配置rsync
发表于 2016-12-23 14:13:29 | 显示全部楼层
1.9.0.0/16
1.32.0.0/17
14.1.128.0/17
第一个这种类型的ip能扫吗
 楼主| 发表于 2016-12-27 06:32:49 | 显示全部楼层

RE: rsync未授权访问验证以及目录获取工具 //支持密码

badbad 发表于 2016-12-23 14:13
1.9.0.0/16
1.32.0.0/17
14.1.128.0/17

不行 你可以加个ip解析的 有现成的库
发表于 2016-12-27 10:13:15 | 显示全部楼层

RE: rsync未授权访问验证以及目录获取工具 //支持密码

xbdg 发表于 2016-12-27 06:32
不行 你可以加个ip解析的 有现成的库

加了。。蛋疼,扫了一些开873端口的ip,没什么回显,也不知道扫的怎么样了
 楼主| 发表于 2016-12-27 11:26:00 | 显示全部楼层

RE: rsync未授权访问验证以及目录获取工具 //支持密码

badbad 发表于 2016-12-27 10:13
加了。。蛋疼,扫了一些开873端口的ip,没什么回显,也不知道扫的怎么样了

大批量扫的话 rsync那块加上超时 有些机器会莫名其妙保持连接 然后就线程全部卡住了
发表于 2016-12-28 12:50:20 | 显示全部楼层
谢谢提供代码,另外NMAP也有现成的script可以扫描rsync及列出目录,但是无法自动继续下层并且自动取得档案,如果可以自动取得档案就好了
rsync-list-modules.nse
发表于 2017-1-2 09:59:42 | 显示全部楼层
楼主发几张效果图让大伙看看呗

九零

GMT+8, 2026-10-22 15:18

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表