aws_recon 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +34 -0
- data/binstub/aws_recon +10 -0
- data/lib/aws_recon/aws_recon.rb +1 -1
- data/lib/aws_recon/collectors/iam.rb +18 -0
- data/lib/aws_recon/collectors/shield.rb +2 -2
- data/lib/aws_recon/lib/formatter.rb +1 -1
- data/lib/aws_recon/lib/mapper.rb +2 -1
- data/lib/aws_recon/version.rb +1 -1
- data/readme.md +42 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 939b12091dee8bd4c6b36877a9954ba43372267edda3b4a1d93d3c5695bfde5b
|
4
|
+
data.tar.gz: fe6dbac4e8001bd82d21bbcb8b22d904f91e864afff58d12a6f86b54d4789d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 120629a6ac6f8839b4f5dea1a0e269133ded6e1679f4e3ca3411965e34cf901d851638edda80450423c6de86ba1701cd00d13b9ea7292cb75881189a98cf4238
|
7
|
+
data.tar.gz: 3d16a17670a9326d3668e7eb37e9fdf883d5dcce1290b368722fc205d37d0a60b58fe850b21211db435f790b1650a44312ede568db41b03537a5fca679373387
|
data/Dockerfile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
ARG RUBY_VERSION=2.6.6
|
2
|
+
FROM ruby:${RUBY_VERSION}-alpine
|
3
|
+
|
4
|
+
LABEL maintainer="Darkbit <info@darkbit.io>"
|
5
|
+
|
6
|
+
ARG USER=recon
|
7
|
+
ARG GEM=aws_recon
|
8
|
+
ARG VERSION=0.2.8
|
9
|
+
ARG BUNDLER_VERSION=2.1.4
|
10
|
+
|
11
|
+
# Install new Bundler version
|
12
|
+
RUN rm /usr/local/lib/ruby/gems/*/specifications/default/bundler-*.gemspec && \
|
13
|
+
gem uninstall bundler && \
|
14
|
+
gem install bundler -v $BUNDLER_VERSION
|
15
|
+
|
16
|
+
# Install gem
|
17
|
+
RUN gem install ${GEM} -v ${VERSION}
|
18
|
+
|
19
|
+
# Create non-root user
|
20
|
+
RUN addgroup -S ${USER} && \
|
21
|
+
adduser -S ${USER} \
|
22
|
+
-G ${USER} \
|
23
|
+
-s /bin/ash \
|
24
|
+
-h /${USER}
|
25
|
+
|
26
|
+
# Copy binstub
|
27
|
+
COPY binstub/${GEM} /usr/local/bundle/bin/
|
28
|
+
RUN chmod +x /usr/local/bundle/bin/${GEM}
|
29
|
+
|
30
|
+
# Switch user
|
31
|
+
USER ${USER}
|
32
|
+
WORKDIR /${USER}
|
33
|
+
|
34
|
+
CMD ["ash"]
|
data/binstub/aws_recon
ADDED
data/lib/aws_recon/aws_recon.rb
CHANGED
@@ -44,7 +44,7 @@ module AwsRecon
|
|
44
44
|
#
|
45
45
|
def collect(service, region)
|
46
46
|
mapper = Object.const_get(service.name)
|
47
|
-
resources = mapper.new(service.name, region, @options)
|
47
|
+
resources = mapper.new(@account_id, service.name, region, @options)
|
48
48
|
|
49
49
|
collection = resources.collect.map do |resource|
|
50
50
|
if @options.output_format == 'custom'
|
@@ -48,6 +48,21 @@ class IAM < Mapper
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
#
|
52
|
+
# list_policies
|
53
|
+
#
|
54
|
+
@client.list_policies.each do |response|
|
55
|
+
log(response.context.operation_name)
|
56
|
+
|
57
|
+
# managed policies
|
58
|
+
response.policies.each do |policy|
|
59
|
+
struct = OpenStruct.new(policy.to_h)
|
60
|
+
struct.type = 'managed_policy'
|
61
|
+
|
62
|
+
resources.push(struct.to_h)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
#
|
52
67
|
# get_account_password_policy
|
53
68
|
#
|
@@ -56,6 +71,7 @@ class IAM < Mapper
|
|
56
71
|
|
57
72
|
struct = OpenStruct.new(response.password_policy.to_h)
|
58
73
|
struct.type = 'password_policy'
|
74
|
+
struct.arn = "arn:aws:iam::#{@account}:account_password_policy/global"
|
59
75
|
|
60
76
|
resources.push(struct.to_h)
|
61
77
|
end
|
@@ -68,6 +84,7 @@ class IAM < Mapper
|
|
68
84
|
|
69
85
|
struct = OpenStruct.new(response.summary_map)
|
70
86
|
struct.type = 'account_summary'
|
87
|
+
struct.arn = "arn:aws:iam::#{@account}:account_summary/global"
|
71
88
|
|
72
89
|
resources.push(struct.to_h)
|
73
90
|
end
|
@@ -111,6 +128,7 @@ class IAM < Mapper
|
|
111
128
|
|
112
129
|
struct = OpenStruct.new
|
113
130
|
struct.type = 'credential_report'
|
131
|
+
struct.arn = "arn:aws:iam::#{@account}:credential_report/global"
|
114
132
|
struct.content = CSV.parse(response.content, headers: :first_row).map(&:to_h)
|
115
133
|
struct.report_format = response.report_format
|
116
134
|
struct.generated_time = response.generated_time
|
@@ -13,7 +13,7 @@ class Shield < Mapper
|
|
13
13
|
|
14
14
|
struct = OpenStruct.new(response.subscription.to_h)
|
15
15
|
struct.type = 'subscription'
|
16
|
-
struct.arn = "arn:aws:shield:#{@region}:#{account}:subscription"
|
16
|
+
struct.arn = "arn:aws:shield:#{@region}:#{@account}:subscription"
|
17
17
|
|
18
18
|
resources.push(struct.to_h)
|
19
19
|
end
|
@@ -26,7 +26,7 @@ class Shield < Mapper
|
|
26
26
|
|
27
27
|
struct = OpenStruct.new
|
28
28
|
struct.type = 'contact_list'
|
29
|
-
struct.arn = "arn:aws:shield:#{@region}:#{account}:contact_list"
|
29
|
+
struct.arn = "arn:aws:shield:#{@region}:#{@account}:contact_list"
|
30
30
|
struct.contacts = response.emergency_contact_list.map(&:to_h)
|
31
31
|
|
32
32
|
resources.push(struct.to_h)
|
@@ -8,7 +8,7 @@ class Formatter
|
|
8
8
|
def custom(account_id, region, service, resource)
|
9
9
|
{
|
10
10
|
account: account_id,
|
11
|
-
name: resource[:arn]
|
11
|
+
name: resource[:arn],
|
12
12
|
service: service.name,
|
13
13
|
region: region,
|
14
14
|
asset_type: resource[:type],
|
data/lib/aws_recon/lib/mapper.rb
CHANGED
@@ -22,7 +22,8 @@ class Mapper
|
|
22
22
|
# S3 (unless the bucket was created in another region)
|
23
23
|
SINGLE_REGION_SERVICES = %w[route53domains s3 shield support organizations].freeze
|
24
24
|
|
25
|
-
def initialize(service, region, options)
|
25
|
+
def initialize(account, service, region, options)
|
26
|
+
@account = account
|
26
27
|
@service = service
|
27
28
|
@region = region
|
28
29
|
@options = options
|
data/lib/aws_recon/version.rb
CHANGED
data/readme.md
CHANGED
@@ -26,7 +26,9 @@ Ruby 2.5.x or 2.6.x (developed and tested with 2.6.5)
|
|
26
26
|
|
27
27
|
### Installation
|
28
28
|
|
29
|
-
|
29
|
+
AWS Recon can be run locally by installing the Ruby gem, or via a Docker container.
|
30
|
+
|
31
|
+
To run locally, first install the gem:
|
30
32
|
|
31
33
|
```
|
32
34
|
$ gem install aws_recon
|
@@ -52,6 +54,20 @@ Using parallel 1.19.2
|
|
52
54
|
Using aws_recon 0.2.2
|
53
55
|
```
|
54
56
|
|
57
|
+
To run via a Docker a container, pass the necessary AWS credentials into the Docker `run` command. For example:
|
58
|
+
|
59
|
+
```
|
60
|
+
$ docker run --rm \
|
61
|
+
-e AWS_REGION \
|
62
|
+
-e AWS_ACCESS_KEY_ID \
|
63
|
+
-e AWS_SECRET_ACCESS_KEY \
|
64
|
+
-e AWS_SESSION_TOKEN \
|
65
|
+
-v $(pwd)/output.json:/recon/output.json \
|
66
|
+
aws_recon:latest \
|
67
|
+
aws_recon -v -s EC2 -r us-east-1,us-east-2
|
68
|
+
```
|
69
|
+
|
70
|
+
|
55
71
|
## Usage
|
56
72
|
|
57
73
|
AWS Recon will leverage any AWS credentials currently available to the environment it runs in. If you are collecting from multiple accounts, you may want to leverage something like [aws-vault](https://github.com/99designs/aws-vault) to manage different credentials.
|
@@ -66,6 +82,31 @@ Plain environment variables will work fine too.
|
|
66
82
|
$ AWS_PROFILE=<profile> aws_recon
|
67
83
|
```
|
68
84
|
|
85
|
+
To run from a Docker container using `aws-vault` managed credentials (output to file):
|
86
|
+
|
87
|
+
```
|
88
|
+
$ aws-vault exec darkbit -- docker run --rm \
|
89
|
+
-e AWS_REGION \
|
90
|
+
-e AWS_ACCESS_KEY_ID \
|
91
|
+
-e AWS_SECRET_ACCESS_KEY \
|
92
|
+
-e AWS_SESSION_TOKEN \
|
93
|
+
-v $(pwd)/output.json:/recon/output.json \
|
94
|
+
aws_recon:latest \
|
95
|
+
aws_recon -s EC2 -v -r us-east-1,us-east-2
|
96
|
+
```
|
97
|
+
|
98
|
+
To run from a Docker container using `aws-vault` managed credentials (output to stdout):
|
99
|
+
|
100
|
+
```
|
101
|
+
$ aws-vault exec darkbit -- docker run --rm \
|
102
|
+
-e AWS_REGION \
|
103
|
+
-e AWS_ACCESS_KEY_ID \
|
104
|
+
-e AWS_SECRET_ACCESS_KEY \
|
105
|
+
-e AWS_SESSION_TOKEN \
|
106
|
+
aws_recon:latest \
|
107
|
+
aws_recon -j -s EC2 -r us-east-1,us-east-2
|
108
|
+
```
|
109
|
+
|
69
110
|
You may want to use the `-v` or `--verbose` flag initially to see status and activity while collection is running.
|
70
111
|
|
71
112
|
In verbose mode, the console output will show:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_recon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Larsen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-09
|
12
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- ".gitignore"
|
153
153
|
- ".rubocop.yml"
|
154
154
|
- ".travis.yml"
|
155
|
+
- Dockerfile
|
155
156
|
- Gemfile
|
156
157
|
- LICENSE.txt
|
157
158
|
- Rakefile
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- bin/aws_recon
|
160
161
|
- bin/console
|
161
162
|
- bin/setup
|
163
|
+
- binstub/aws_recon
|
162
164
|
- lib/aws_recon.rb
|
163
165
|
- lib/aws_recon/aws_recon.rb
|
164
166
|
- lib/aws_recon/collectors.rb
|