ARL

ARL,第1张

ARL(资产侦察灯塔系统)-源码搭建

freebuf能力中心开源了一套资产扫描系统(https://github.com/TophantTechnology/ARL),提供docker版,但并无源码搭建的文档(无完整文档)。


于是在星光哥及小明哥指导下完成源码搭建,在这里记录一下。


环境
  • centos7.6 2h4g
搭建过程

首先从github下载源码,我下载到opt 目录下。


phantomjs

先在官网下载phantomjs

# 下载
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
# 解压
tar -jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
# 修改环境变量
vim /etc/profile
# 刷新环境变量
source /etc/profile
# 验证
phantomjs --version

/etc/profile文件末尾增加如下内容(路径看自己解压完放哪)

export PATH=$PATH:/opt/phantomjs-2.1.1-linux-x86_64/bin
安装相关软件包
yum install epel-release
yum install rabbitmq-server supervisor
yum install wqy-microhei-fonts fontconfig
rabbitmq-server

上面已经安装了rabbitmq-server

# 启动
systemctl start rabbitmq-server # 配置
rabbitmqctl add_user arl arlpassword
rabbitmqctl add_vhost arlvhost
rabbitmqctl set_user_tags arl arltag
rabbitmqctl set_permissions -p arlvhost arl ".*" ".*" ".*"
nmap

下载nmap

https://nmap.org/dist/nmap-7.80-1.x86_64.rpm

# 安装
rpm -ivh nmap-7.80-1.x86_64.rpm
mongoDB

vim /etc/yum.repos.d/mongodb-org-4.0.repo

[mngodb-org]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/4.0/x86_64/
gpgcheck=0
enabled=1

安装yum -y install mongodb-org

开启无IP限制(方便看数据)

vim /etc/mongod.conf
service mongod restart

mongodb 添加认证

# mongo
> use arl
> db.createUser({user:'admin',pwd:'admin',roles:[{role:'dbOwner',db:'arl'}]})
> exit

开启登录验证

# 关闭数据库
service mongod stop # 开启验证登录
vim /etc/mongod.conf

security:

authorization: enabled


# service mongod start

添加账号密码

mongo -u admin -p admin --authenticationDatabase "arl"

use arl
db.user.insert({ username: 'admin123', password: hex_md5('arlsalt!@#'+'admin123') })
exit
GeoIP数据库

由于官方政策更新请前往maxmind注册下载GeoLite2-City.tar.gzGeoLite2-ASN.tar.gz 解压。


config.yaml中配置好相关路径。


我放在了/data/GeoLite2

config.yaml配置

添加并修改配置文件

cp app/config.yaml.example app/config.yaml

我的配置

CELERY:
BROKER_URL : "amqp://arl:arlpassword@localhost:5672/arlvhost" MONGO:
URI : 'mongodb://admin:admin@localhost:27017/arl'
DB : 'arl' RISKIQ:
EMAIL: "[email protected]"
KEY: "03da3c29cce5152a536bae332f7b03a288154b37a13b93921225d3ade49c9b4c" GEOIP:
CITY: '/data/GeoLite2/GeoLite2-City.mmdb'
ASN: '/data/GeoLite2/GeoLite2-ASN.mmdb' FOFA:
EMAIL: ""
KEY: "" ARL:
AUTH: true
API_KEY: ""
BLACK_IPS:
- 127.0.0.0/8
#- 0.0.0.0/8
#- 172.16.0.0/12
#- 100.0.0.0/8
#- 10.0.0.0/8
#- 192.168.0.0/16
nginx
# centOS7.6下安装nginx
cd /yum install gcc gcc-c++ # 安装依赖
wget http://nginx.org/download/nginx-1.17.1.tar.gz # 下载nginx源码
tar -zxvf nginx-1.17.1.tar.gz # 解压
cd nginx-1.17.1 # 进入解压后的文件夹
./configure --prefix=/usr/local/nginx # 配置nginx安装路径
make
make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx # 创建nginx软链接,若已被占用,则在 /usr/bin 下 rm-rf nginxnginx # 启动ngixnnginx -s stop # 停止nginx服务

导入配置nginx.conf,这边直接用root启动了(根据自身修改用户)。


user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80;
server_name _; #access_log logs/host.access.log main;
access_log off;
root /opt/ARL-master/docker/frontend; location / {
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /api/ {
proxy_pass http://127.0.0.1:5003/api/;
}
} }

nginx启动。


无报错,前端则启动成功。


后端启动

安装依赖

pip3 install -r requirements.txt

WEB 服务启动

gunicorn -b 0.0.0.0:5003 app.main:arl_app -w 3 --access-logfile arl_web.log

CELERY 启动

celery -A app.celerytask.celery worker -l info -Q arltask -n arltask -c 2 -O fair -f arl_worker.log

利用tmux+supervisior启动。


安装tmux

yum install -y tmux

在项目根目录编写supervisior文件

supervisior.conf

[program:web_api]
command=gunicorn -b 0.0.0.0:5003 app.main:arl_app -w 3 --access-logfile /var/log/arl_web.log
;stdout_logfile=/var/log/web_api_stdout.log
;stderr_logfile=/var/log/web_api_stderr.log
autostart=true
autorestart=true [program:celery_scan]
command=celery -A app.celerytask.celery worker -l info -Q arltask -n arltask -c 2 -O fair -f arl_worker.log
;stdout_logfile=/var/log/celery_scan_stdout.log
;stderr_logfile=/var/log/celery_scan_stderr.log
autostart=true
autorestart=true [unix_http_server]
file=/tmp/supervisor.sock ; the path to the socket file [supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
loglevel=info ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=true ; start in foreground if true; default false
minfds=1024 ; min. avail startup file descriptors; default 1024
minprocs=200 ; min. avail process descriptors;default 200 [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
# 新建一个窗口
tmux new -s sp # 在项目根目录运行
supervisord -c supervisord.conf # 会话后台运行
ctrl + b + d # 进入会话
tmux a -t sp

运行成功

使用

直接访问该IP

admin123/admin123登录

添加任务并看结果



查看API文档并测试

结尾

使用了下,在资产探测收集还是很不错的,日站收集资产神器。


而且是开源,也提供了API出来。


在后续二开也很方便的。


感谢开源!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/587402.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存