Giter VIP home page Giter VIP logo

geoip-attack-map's Introduction

First and Foremost

I do not have much time in my life right now to maintain this project. I undertook this challenge as a means to learn JavaScript, and to improve upon the Python I already knew. I'm sure there are several things I could have done differently in my implementation, and I won't be offended if I receive constructive criticism from someone who downloads and views my code. I know I learned a ton when working on this, and I hope the open source community will continue to teach me things :)

NOTE: Because I don't maintain this project there are a few features that probably don't work out the box, for example, the map probably won't display because I don't pay for a legitimate MapBox API key. To fix this you will probably have to create your own MapBox account and use your own key.

Cyber Security GeoIP Attack Map Visualization

This geoip attack map visualizer was developed to display network attacks on your organization in real time. The data server follows a syslog file, and parses out source IP, destination IP, source port, and destination port. Protocols are determined via common ports, and the visualizations vary in color based on protocol type. CLICK HERE for a demo video. This project would not be possible if it weren't for Sam Cappella, who created a cyber defense competition network traffic visualizer for the 2015 Palmetto Cyber Defense Competition. I mainly used his code as a reference, but I did borrow a few functions while creating the display server, and visual aspects of the webapp. I would also like to give special thanks to Dylan Madisetti as well for giving me advice about certain aspects of my implementation.

Important

This program relies entirely on syslog, and because all appliances format logs differently, you will need to customize the log parsing function(s). If your organization uses a security information and event management system (SIEM), it can probably normalize logs to save you a ton of time writing regex.

  1. Send all syslog to SIEM.
  2. Use SIEM to normalize logs.
  3. Send normalized logs to the box (any Linux machine running syslog-ng will work) running this software so the data server can parse them.

Configs

  1. Make sure in /etc/redis/redis.conf to change bind 127.0.0.1 to bind 0.0.0.0 if you plan on running the DataServer on a different machine than the AttackMapServer.
  2. Make sure that the WebSocket address in /AttackMapServer/index.html points back to the IP address of the AttackMapServer so the browser knows the address of the WebSocket.
  3. Download the MaxMind GeoLite2 database, and change the db_path variable in DataServer.py to the wherever you store the database.
    • ./db-dl.sh
  4. Add headquarters latitude/longitude to hqLatLng variable in index.html
  5. Use syslog-gen.py, or syslog-gen.sh to simulate dummy traffic "out of the box."
  6. IMPORTANT: Remember, this code will only run correctly in a production environment after personalizing the parsing functions. The default parsing function is only written to parse ./syslog-gen.sh traffic.

Bugs, Feedback, and Questions

If you find any errors or bugs, please let me know. Questions and feedback are also welcome, and can be sent to [email protected], or open an issue in this repository.

Deploy example

Tested on Ubuntu 16.04 LTS.

  • Clone the application:

    git clone https://github.com/matthewclarkmay/geoip-attack-map.git
  • Install system dependencies:

    sudo apt install python3-pip redis-server
    
  • Install python requirements:

    cd geoip-attack-map
    sudo pip3 install -U -r requirements.txt
    
  • Start Redis Server:

    redis-server
    
  • Configure the Data Server DB:

    cd DataServerDB
    ./db-dl.sh
    cd ..
    
  • Start the Data Server:

    cd DataServer
    sudo python3 DataServer.py
    
  • Start the Syslog Gen Script, inside DataServer directory:

    • Open a new terminal tab (Ctrl+Shift+T, on Ubuntu).

      ./syslog-gen.py
      ./syslog-gen.sh
  • Configure the Attack Map Server, extract the flags to the right place:

    • Open a new terminal tab (Ctrl+Shift+T, on Ubuntu).

      cd AttackMapServer/
      unzip static/flags.zip
  • Start the Attack Map Server:

    sudo python3 AttackMapServer.py
  • Access the Attack Map Server from browser:

    • http://localhost:8888/ or http://127.0.0.1:8888/

    • To access via browser on another computer, use the external IP of the machine running the AttackMapServer.

    • Edit the IP Address in the file "/static/map.js" at "AttackMapServer" directory. From:

      var webSock = new WebSocket("ws:/127.0.0.1:8888/websocket");
    • To, for example:

      var webSock = new WebSocket("ws:/192.168.1.100:8888/websocket");
    • Restart the Attack Map Server:

      sudo python3 AttackMapServer.py
    • On the other computer, points the browser to:

      http://192.168.1.100:8888/

geoip-attack-map's People

Contributors

diegodblr avatar matthewclarkmay avatar nullelement avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geoip-attack-map's Issues

unable to display the map

capture3

Hey guys,

When I install geoip-map-attack everything works fine except the world map display.

Can you help Me Please.

Thanks

Problem

Hello

Can you help me with your application.
I try to make it work on a fresh Ubuntu Server 16.04.2 LTS.
Installation successful.

Redis-server is active
sudo service redis-server status
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2017-03-17 18:57:18 MSK; 2 days ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 1147 (redis-server)
Tasks: 3
Memory: 2.0M
CPU: 3min 12.186s
CGroup: /system.slice/redis-server.service
└─1147 /usr/bin/redis-server 0.0.0.0:6379

Mar 17 18:57:18 geoip systemd[1]: Starting Advanced key-value store...
Mar 17 18:57:18 geoip run-parts[1085]: run-parts: executing /etc/redis/redis-server.pre-up.d/00_example
Mar 17 18:57:18 geoip run-parts[1148]: run-parts: executing /etc/redis/redis-server.post-up.d/00_example
Mar 17 18:57:18 geoip systemd[1]: Started Advanced key-value store.

  1. I start sudo python3 DataServer.py
  2. In another session I run ./syslog-gen.sh
  3. I see some events in first session with DataServer.py
  4. In another new session I start sudo python3 AttackMapServer.py - (see [*] Waiting on browser connections...)
  5. Open a browser and open a link of server:8888 - (map is open, I see a hq_point, but no traffic activities)
  6. In AttackMapServer.py session - I get an error
    geoip@geoip:/opt/geoip-attack-map/AttackMapServer$ sudo python3 AttackMapServer.py
    [sudo] password for geoip:
    [] Waiting on browser connections...
    [
    ] WebSocketChatHandler opened
    [] Connected to Redis server
    [
    ] Closing connection.
    ERROR:tornado.application:Exception in callback <function wrap..null_wrapper at 0x7f9c17c4d048> for <tornado.concurrent.Future object at 0x7f9c17c945f8>
    Traceback (most recent call last):
    File "/usr/local/lib/python3.5/dist-packages/tornado/concurrent.py", line 322, in _set_done
    cb(self)
    File "/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
    File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 199, in final_callback
    if future.result() is not None:
    File "/usr/local/lib/python3.5/dist-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
    File "", line 3, in raise_exc_info
    File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 1024, in run
    yielded = self.gen.send(value)
    File "/usr/local/lib/python3.5/dist-packages/tornadoredis/client.py", line 1164, in listen
    callback(result)
    File "AttackMapServer.py", line 234, in on_message
    self.write_message(json.dumps(msg_to_send))
    File "/usr/local/lib/python3.5/dist-packages/tornado/websocket.py", line 210, in write_message
    raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
    WARNING:tornado.access:404 GET /favicon.ico (10.21.124.135) 0.98ms

What I do wrong?
I try to check redis connection
redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
Seems it work...

How to make it work?

Map point from Source IP to Dest IP

Hi,

This project is really amazing. However, I'm trying to point attack source ip to destination ip on map instead of limiting to headquarters (based on info from syslog). So it would be a great help if you can point me on how to get this done..

Thanks!!

WebSocket connection refused

WebSocket connection to 'ws://127.0.0.1:8888/websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
image

Separate HTML and JavaScript

I like seeing what percentage of the project is HTML, Python, JavaScript, Bash, etc, so I'm thinking about separating the HTML and JavaScript into separate files (index.html, and index.js).

Thoughts/Ideas?

new feature (target)

I created a new feature. I removed the first table, the one that shows the colors and the protocols, and added a new one in which the quantity and the target ip appear. Thus it is possible to know which network ips are more and / or less attacked.

mapbox API limit reaced

Hi,

It seems that you included your own apikey for mapbox. So it seems you have run out of api calls. I registered my own account on mapbox however my account doesn't have the map that is being used ("mmay601.p9if994e") Is there any way you can share it or explain how to create the map that is currently used?

Thank you in advanced.

mapbox background map is not being displayed

All data is processed normally, but the mapbox background map is not rendered to web page as shown on the screen in attach. I've tried to generate a new access token - that did solve the 401 error code issue, but now I get the 404 when JS is trying to access the mapbox url.
img2
img1

Truncate /var/log/syslog, or read from end?

If there are residual logs in /var/log/syslog, they will all be processed by DataServer.py when initialized. I would prefer if it only processed real time events.

Two options:

  1. Truncate /var/log/syslog when DataServer.py is initialized.
  2. Start reading from end of /var/log/syslog.

Thoughts/Ideas?

Configure With Arcsight ESM

Hello,

Hope you doing well.
How can i configure geoIP-attack-map with my Arcsight ESM.
Can you please help out for this issue.

Thanking you.
Devang Raval.

Unable to parse logs from /var/log/syslog correctly

Hello, i just recently set up my geoip-attack-map, everything works fine when am using dummy traffic, i have a SIEM that has been configured to send logs to the Attackmap server but whenever i run Dataserver.py it shows NOT A VALID LOG. Is there a solution for this??

geoip attack map DAEMON

To facilitate the task of stopping and starting the process, follow the process I did:

OS: Debian

cd /etc/systemd/system/

nano geoipattack1.service

[Unit]
Description = Geoip Attack Snort LOG
After = syslog.target network.target

[Service]
Type = simple
ExecStart = / home/user/geoip-attack-map/AttackMapServer/AttackMapServer.py

[Install]
WantedBy = multi-user.target

nano geoipattack2.service

[Unit]
Description = Geoip Attack Snort LOG DATA
After = syslog.target network.target

[Service]
Type = simple
ExecStart = /home/ user/geoip-attack-map/DataServer/DataServer.py

[Install]
WantedBy = multi-user.target

systemctl daemon-reload

systemctl start geoipattack1

systemctl start geoipattack2

systemctl stop geoipattack1

systemctl stop geoipattack2

Memory Use / Variable Size

One of the big issues with DataServer.py is that memory is constantly consumed. Variables are ever growing, and this needs to change, so maybe we should use a database? I'm thinking we incorporate mongodb, and track metrics there. That way variables aren't tracking metrics the entire time, and we save on memory space.

Thoughts/Ideas?

Constants

There are currently several constant variable included in DataServer.py and AttackMapServer.py. Should we add these to one file and import them?

Thoughts/Ideas?

how can I make a same map just use my own token

I build the map in my server some days.
But yesterday,I find the token have some problems.
It seems the token is out of time.
How can I use Mapbox and get a map same as yours with my own token.
Thanks!

raspberry pi

Please can this be done on a raspberry pi 3....
Thanks

Plot by dst_ip.

Hello,

First off I love this map. It's a nice KISS (Keep It Simple Stupid) approach which I've been looking for. Thank you for developing it.

I've been able to feed the map from our SIEM without an issue. One thing I've noticed is the is seems to plot from src_ip -> hqLatLng (from the static/map.js). We have multiple sites around the county and it would be useful for it to plot from src_ip -> dst_ip.

Is this possible with the current code? It seems to take the dst_ip from the feed but I don't see where it actually uses it along with the maxmind data to plot from src -> dst.

If it does not, I'll see what I can kludge together. Thank you again.

simulate dummy traffic

How to slow down the speed of simulate dummy traffic?The lines on the map are very messy.

toLowerCase() in index.html

Has happened to give error in the application when the amount of logs is very great and very fast. I have checked that the java script toLowerCase () function used to put flag images is to blame. I have adopted a simple solution here:

// var path = 'flags /' + args [i] .toLowerCase () + '.png';
Var path = 'flags /' + args [i] + '.png';

I removed toLowerCase () and used a shell script function to rename by capitalizing the acronyms of countries in the flags directory. Resolved for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.