渗透|渗透技巧——通过Exchange ActiveSync访问内部文件共享( 二 )


print("%s 192.168.1.1 user1 password1"%(sys.argv[0]))
sys.exit(0)
else:
test_options_https(sys.argv[1], sys.argv[2], sys.argv[3])
0x04 Exchange ActiveSync开源代码测试
1.https://github.com/solbirn/pyActiveSync
需要使用Python2 。
为了能够正常测试 , 还需要如下设置:
(1)同级目录下新建文件proto_creds.py
内容如下:
as_server="192.168.1.1"
as_user="user1"
as_pass="password1"
(2)取消对SSL证书的验证
修改pyActiveSyncobjectsMSASHTTP.py
添加引用import ssl
将httplib.HTTPSConnection(self.server, self.port) 替换为httplib.HTTPSConnection(self.server, self.port, context=ssl._create_unverified_context())
(3)修改pyActiveSync/dev_playground.py
去掉"Suggested Contacts"相关代码 。
分别运行dev_playground.py和misc_tests.py , 对应不同的功能 。
2.https://github.com/FSecureLABS/peas
需要使用Python2 。
基于pyActiveSync , 添加了导出邮件和访问共享文件的功能 。
常用功能如下:
(1)验证凭据
代码示例:
import peas
# Create an instance of the PEAS client.

client = peas.Peas()
# Disable certificate verification so self-signed certificates don"t cause errors.
client.disable_certificate_verification()
# Set the credentials and server to connect to.
client.set_creds({
"server": "192.168.1.1",
"user": "test1",
"password": "123456789",
})
# Check the credentials are accepted.
print("Auth result:", client.check_auth())
(2)读取邮件
读取收件箱邮件的代码示例:
import peas
import re
# Create an instance of the PEAS client.
client = peas.Peas()
# Disable certificate verification so self-signed certificates don"t cause errors.
client.disable_certificate_verification()
# Set the credentials and server to connect to.
client.set_creds({
"server": "192.168.1.1",
"user": "test1",
"password": "123456789",
})
# Retrieve emails.
emails = client.extract_emails()
for email in emails :
print("")
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")
data = http://news.hoteastday.com/a/pattern_data.findall(email)
print("To:"+data[0])
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")
data = http://news.hoteastday.com/a/pattern_data.findall(email)
print("From:"+data[0])
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")
data = http://news.hoteastday.com/a/pattern_data.findall(email)
print("Subject:"+data[0])
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")
data = http://news.hoteastday.com/a/pattern_data.findall(email)

print("DateReceived:"+data[0])
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")
data = http://news.hoteastday.com/a/pattern_data.findall(email)
print("DisplayTo:"+data[0])
pattern_data = http://news.hoteastday.com/a/re.compile(r"(.*?)")


推荐阅读