Skip to content

Commit 81ea090

Browse files
committed
2 parents 5381cae + 41667b9 commit 81ea090

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,120 @@
11
# attack-surface-detector-cli
2+
3+
The `attack-surface-detector-cli` program is a command-line tool that takes in a folder location and outputs the set of endpoints detected within that codebase. It uses the [ASTAM Correlator's](https://github.com/secdec/astam-correlator) `threadfix-ham` module to generate these endpoints.
4+
## Usage
5+
6+
Once you have a compiled JAR, run the program with:
7+
8+
java -jar attack-surface-detector-cli.jar <root-folder> [-flags]
9+
10+
If successful, you should see various output in the console regarding endpoints declared in the given code.
11+
12+
> java -jar attack-surface-detector-cli.jar "C:\.....\AltoroJ 3.1.1"
13+
Beginning endpoint detection for 'C:\.....\AltoroJ 3.1.1'
14+
Using framework=JSP
15+
Generated 47 distinct endpoints with 26 variants for a total of 73 endpoints
16+
[0] GET: /admin/admin.jsp (1 variants): PARAMETERS={}; FILE=/WebContent/admin/admin.jsp (lines '1'-'194')
17+
[1] -- POST: /admin/admin.jsp (0 variants): PARAMETERS={}; FILE=/WebContent/admin/admin.jsp (lines '1'-'194')
18+
[2] GET: /admin/feedbackReview.jsp (1 variants): PARAMETERS={}; FILE=/WebContent/admin/feedbackReview.jsp (lines '1'-'75')
19+
[3] -- POST: /admin/feedbackReview.jsp (0 variants): PARAMETERS={}; FILE=/WebContent/admin/feedbackReview.jsp (lines '1'-'75')
20+
21+
...
22+
23+
-- DONE --
24+
Generated 73 total endpoints
25+
Generated 50 total parameters
26+
To enable logging include the -debug argument
27+
28+
## Saving to JSON
29+
30+
The detected endpoints can be serialized and stored in a JSON file. This is done using the `-json` and `-output=...` parameters:
31+
32+
> java -jar attack-surface-detector-cli.jar C:\...\SourceCode -json -output=C:\...\endpoints.json
33+
34+
This `json` output carries extra information and is intended to be used with the `threadfix-ham` module from the ASTAM Correlator through `com.denimgroup.threadfix.framework.engine.full.EndpointSerialization.deserializeAll(..)`. A simplified output can be created by using the `-simple-json` flag instead of `-json`. See the Options section below for more details.
35+
36+
## Options
37+
38+
<folder-path>
39+
Runs endpoint detection on code location in the given folder path. _(Required, unless -path-list-file=... is specified)_
40+
41+
***
42+
43+
-framework=<framework>
44+
Specifies the web framework used in the given code location. If undefined, the HAM module will attempt to detect the framework type automatically. Accepted values at time of writing are:
45+
1. `JSP` (Java JSP and Servlets)
46+
2. `DOT_NET_MVC` (ASP.NET MVC)
47+
3. `DOT_NET_WEB_FORMS` (ASP.NET Web Forms)
48+
4. `STRUTS`
49+
5. `SPRING_MVC`
50+
6. `RAILS` (Ruby on Rails)
51+
7. `PYTHON` (Django)
52+
53+
***
54+
55+
-debug
56+
Enables `DEBUG` log messages.
57+
58+
***
59+
60+
-simple
61+
Disables diagnostic messages that are usually output by the tool.
62+
63+
***
64+
65+
-path-list-file="/path/to/list.txt"
66+
Runs endpoint detection on each code location specified in the given file list. An example can be found [here.](https://github.com/secdec/astam-correlator/blob/master/threadfix-cli-endpoints/sample-project-list.txt)
67+
68+
***
69+
70+
-json
71+
Outputs a complete JSON-serialized version of the detected endpoints, intended for deserialization by the `threadfix-ham` module. Endpoints are stored with framework-specific content, wrapped in an object indicating the framework type for that endpoint.
72+
73+
If multiple projects are scanned at once, the JSON output will contain a single array of all endpoints from all scanned projects.
74+
75+
***
76+
77+
-simple-json
78+
Outputs a simplified JSON-serialized version of the detected endpoints, intended for use by any JSON parser. It provides a consistent and simplified format for all generated endpoints.
79+
80+
If multiple projects are scanned at once, the JSON output will contain a single array of all endpoints from all scanned projects.
81+
82+
***
83+
84+
-output=...
85+
Specifies an output file that endpoints will be written to when using JSON serialization. This requires either `-json` or `-simple-json` to also be set, otherwise this flag has no effect.
86+
87+
## Build Instructions
88+
The module can be built with maven:
89+
90+
C:\...\attack-surface-detector-cli> mvn clean package
91+
92+
You'll find the compiled JAR at `.../target/attack-surface-detector-cli-<version>-jar-with-dependencies.jar`.
93+
94+
For simplicity, this `jar` is referred to as `attack-surface-detector-cli.jar` throughout this guide.
95+
96+
97+
## Debug Information
98+
99+
The console output can include various debug information at the end of a scan for validation. This typically looks like:
100+
101+
Got an absolute file path when a relative path was expected instead, for: GET,/^(?P<i18>[\w\-_]+)/^admin/^mypageextension/$,{}
102+
Failed to validate serialization for at least one of these endpoints
103+
251 endpoints were missing code start line
104+
251 endpoints were missing code end line
105+
0 endpoints had the same code start and end line
106+
Generated 38 parameters
107+
- 38/38 have their data type
108+
- 0/38 have a list of accepted values
109+
- 0/38 have their parameter type
110+
--- UNKNOWN: 38
111+
112+
Endpoints without a line range will have their start and end lines set to `-1`. Parameters are associated with a name, data type, and parameter type, which are summarized at the end. The parameter types are:
113+
114+
- `UNKNOWN` - The parameter type could not be detected
115+
- `QUERY_STRING` - A parameter stored in the URL of the request ie `/index.php?query=value`
116+
- `FORM_DATA` - Any form-type data. Can also be used to store the body of a request
117+
- `PARAMETRIC_ENDPOINT` - A parameter embedded in the URL, ie `/books/{bookId}/order`
118+
- `SESSION` - A parameter stored as session data
119+
- `COOKIE` - A parameter stored as a cookie
120+
- `FILES` - A parameter for file uploads

0 commit comments

Comments
 (0)