Skip to content

Commit 78875cc

Browse files
committed
updates to scot4-inbox
1 parent 006f965 commit 78875cc

25 files changed

+2740
-202
lines changed

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Start with debian:bookworm image with scot4 perl installed
2+
FROM ghcr.io/sandialabs/scot4-perl-builder@sha256:6a92390d96baf3c1ad73fcdf9af5047a36e880c5ce026c91cff98d0064e2e67f
3+
4+
# Create necessary directories
5+
RUN mkdir -p /opt/scot4-inbox && mkdir -p /var/log/scot
6+
7+
# Copy over required files
8+
COPY . /opt/scot4-inbox
9+
10+
# create user/group for scotinbox
11+
RUN groupadd scotinbox && \
12+
useradd -c "Scot Inbox User" -g "scotinbox" -d /opt/scot4-inbox -M -s /bin/bash scotinbox && \
13+
chown -R scotinbox:scotinbox /opt/scot4-inbox && \
14+
chown -R scotinbox:scotinbox /var/log/scot
15+
16+
# start container as scotinbox user
17+
USER scotinbox
18+
19+
# airflow will handle start, but if not
20+
ENTRYPOINT ["/opt/scot4-inbox/bin/inbox.pl"]
21+
CMD ["-?"]

LICENSE

-201
This file was deleted.

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# scot4-inbox
2-
SCOT4 Inbox Processor
2+
3+
4+
# Inbox (IMAP/MSGRAPH) processor for SCOT4
5+
6+
Creates a container to run the SCOT4 inbox processor. The processor will read IMAP inboxes and Microsoft Graph API inboxes and insert the contents of those messages into SCOT alerts, events, or dispatches.
7+
8+
This is a convenient way to input data from detection systems, threat intel feeds, and analysts directly into SCOT.
9+
10+
For more information and instructions, consult the main SCOT4 documentaton Repository.

bin/delete.pl

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/opt/perl/bin/perl
2+
3+
use lib '/opt/scot4-inbox/lib';
4+
use lib '../lib';
5+
use Mojo::Base -strict, -signatures;
6+
use Scot::Inbox::Processor;
7+
use Getopt::Long qw(GetOptions);
8+
9+
my $pidfile = "/tmp/scot.inboxdelete.pid";
10+
11+
if ( -s $pidfile ) {
12+
die "$pidfile exists. Kill running $0 and delete $pidfile to continue";
13+
}
14+
15+
open(my $fh, ">", $pidfile) or die "Unable to write to $pidfile!";
16+
print $fh "$$";
17+
close($fh);
18+
19+
END {
20+
system("rm -f $pidfile");
21+
}
22+
23+
# option defaults
24+
my $configfile = "../etc/inbox.conf";
25+
my $test = 0;
26+
my $secrets = "../etc/secrets.conf";
27+
my $msv = 1;
28+
my $nomsv = 0;
29+
my $msvlog = "/opt/scot4-inbox/var/log/msv.log";
30+
31+
my $default_note = <<EOF;
32+
note: default config is $configfile
33+
default secrets is $secrets
34+
default msvlog is $msvlog
35+
36+
EOF
37+
38+
GetOptions(
39+
'config=s' => \$configfile,
40+
'test' => \$test,
41+
'secrets=s' => \$secrets,
42+
'msv' => \$nomsv,
43+
'msvlog' => \$msvlog,
44+
) or die <<EOF;
45+
46+
Invalid Option!
47+
48+
usage: $0
49+
[--test] overwrites peeking to true
50+
[--config=/path/to/inbox.conf] use this file as the configuration file
51+
[--secrets=/path/to/secrets.conf] use this file for secret storage
52+
[--msv] do not filter msv data
53+
[--msvlog=/path/to/log] where to log msv hits
54+
55+
$default_note
56+
EOF
57+
58+
if ($nomsv) {
59+
$msv = 0;
60+
}
61+
62+
my $opts = {
63+
configfile => $configfile,
64+
test => $test,
65+
secrets => $secrets,
66+
msv => $msv,
67+
msvlog => $msvlog,
68+
delete_before => time() - (2 * 365 * 24 * 3600)
69+
};
70+
71+
Scot::Inbox::Processor->new($opts)->delete();
72+
73+
74+

bin/inbox.pl

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/opt/perl/bin/perl
2+
3+
use lib '/opt/scot4-inbox/lib';
4+
use lib '../lib';
5+
use Mojo::Base -strict, -signatures;
6+
use Scot::Inbox::Processor;
7+
use Getopt::Long qw(GetOptions);
8+
9+
my $pidfile = "/tmp/scot.inbox.pid";
10+
11+
if ( -s $pidfile ) {
12+
die "$pidfile exists. Kill running $0 and delete $pidfile to continue";
13+
}
14+
15+
open(my $fh, ">", $pidfile) or die "Unable to write to $pidfile!";
16+
print $fh "$$";
17+
close($fh);
18+
19+
END {
20+
system("rm -f $pidfile");
21+
}
22+
23+
# option defaults
24+
my $configfile = "../etc/inbox.conf";
25+
my $test = 0;
26+
my $secrets = "../etc/secrets.conf";
27+
my $msv = 1;
28+
my $nomsv = 0;
29+
my $msvlog = "/opt/scot4-inbox/var/log/msv.log";
30+
31+
my $default_note = <<EOF;
32+
note: default config is $configfile
33+
default secrets is $secrets
34+
default msvlog is $msvlog
35+
36+
EOF
37+
38+
GetOptions(
39+
'config=s' => \$configfile,
40+
'test' => \$test,
41+
'secrets=s' => \$secrets,
42+
'msv' => \$nomsv,
43+
'msvlog' => \$msvlog,
44+
) or die <<EOF;
45+
46+
Invalid Option!
47+
48+
usage: $0
49+
[--test] overwrites peeking to true
50+
[--config=/path/to/inbox.conf] use this file as the configuration file
51+
[--secrets=/path/to/secrets.conf] use this file for secret storage
52+
[--msv] do not filter msv data
53+
[--msvlog=/path/to/log] where to log msv hits
54+
55+
$default_note
56+
EOF
57+
58+
if ($nomsv) {
59+
$msv = 0;
60+
}
61+
62+
my $opts = {
63+
configfile => $configfile,
64+
test => $test,
65+
secrets => $secrets,
66+
msv => $msv,
67+
msvlog => $msvlog,
68+
};
69+
70+
Scot::Inbox::Processor->new($opts)->run();
71+
72+
73+

0 commit comments

Comments
 (0)