Giter Club home page Giter Club logo

sam's Introduction

SAM - System Architecture Mapper

SAM is a tool designed to map a network based on the data log of a router. It runs as a local python-based server and displays the a map and statistics on the browser.

Check out the website for details about the project and a demo!

Quickstart (using pip)

install SAM with pip:

pip install samapper

Collect network data with tcpdump and run the http server:

sudo tcpdump -i any -f --immediate-mode -l -n -Q inout -tt | samapper --local --whois --format=tcpdump
  • tcpdump will probably need to be run with sudo to allow it to capture network traffic from your devices.
  • Only tcpdump format works locally via pipe at the moment.

Or, run the http server without collecting data:

samapper --local --whois --format=none

Known issue:

When running samapper in local mode using sqlite (the default) the database will sometimes lock up when the collector is inserting and you are viewing the display. If this is happening, just run the collector for a while, stop it, and run the http server on its own.

Installation (using git)

Prerequisites

(optional) mysql - database software that will work better for this than sqlite.

apt-get install mysql-server libmysqlclient-dev python python-dev

pip - to install python packages

apt-get install python-pip

Installing

  1. Clone this repository
  2. Run pip install -r requirements.txt from within the directory to install necessary packages.
  3. Set environment variables for credentials and settings. See sam/default.cfg.
e.g:
export SAM__DATABASE__DBN=mysql
export SAM__DATABASE__USER=root
export SAM__DATABASE__PW=mypassword

Usage

  1. Start the server locally by running: python -m sam.launcher --target=webserver For a more robust deployment, SAM supports the WSGI interface (python sam/server_webserver.py) and can be run through a different web server.

  2. Create a data source to use in the settings page, or use the default empty data source provided.

  3. For static analysis, import your log files into the database by running the following scripts, where log_file is the path to your log file and destination is the name of the data source you wish to fill.

    python -m sam.launcher --target=import --format=<format> --dest=<destination> <log_file>

    Log formats currently supported include:

    1. paloalto: The paloalto syslog format is expected.
    2. nfdump: Binary files from nfcapd are expected. nfdump must be installed.
    3. asa: Cisco ASA logs, Partial support. Thanks to Emre for contributing.
    4. aws: AWS VPC Flow logs: Partial support. Thanks to Emre for contributing. VPC log spec
    5. tcpdump: Designed to work with live local mode. See quickstart above
    6. tshark: Partial support.
  4. For live analysis,

    1. On the settings page, choose a data source for your live data to be funneled into then create a Access Key
    2. Edit default.cfg or set an environment variable (SAM__COLLECTOR__UPLOAD_KEY) to your new access key
    3. Start the aggregator (this loads log data into the database)
      • python -m sam.launcher --target=aggregator
    4. Start the collector (this listens to port 514 and translates syslog lines)
      • python -m sam.launcher --target=collector
      • You will need priviledges to bind to system port 514.
      • It should print "Testing connection... Succeeded."
    5. Tell your router to output it's log files to that freshly opened socket.
  5. Navigate your browser to localhost:8080 and explore your network!

sam's People

Contributors

jacobfrank4 avatar joepelz avatar johnagapeyev avatar mgoerwell avatar natureclient avatar rrezel 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

sam's Issues

NameError: global name 'convert' is not defined

Traceback (most recent call last):
File "import_paloalto.py", line 117, in
main(sys.argv)
File "import_paloalto.py", line 109, in main
import_file(argv[1])
File "import_paloalto.py", line 68, in import_file
translated_line = translate(line, lineNum);
File "import_paloalto.py", line 53, in translate
return (convert(*(split_data[7].split("."))),
NameError: global name 'convert' is not defined

Feature: Use Elasticsearch ES5.x o ES6.x

Hi,

This project is awesome, but I think that if you migrate SQL to ES, it will be more faster in query and more easy deploy.

Even, it's possible to get pcap and export it to Elasticsearch database, and another feature will be able to get data from ES to SMAMapper !

Thanks!

render issue at max zoom

When fully zoomed in (at host level) there are sometimes issues in the rendering of circles and arrows.
Problems have been observed in Firefox on Linux, and Opera (chromium) on Windows.

zooming out from max level fixes issue. Could be floating point precision somewhere along the line?
attached: image of two arrows not drawing correctly.
arrow_glitch
And the intended #appearance:
arrow_nonglitch

filter by string

the map's port filter accepts strings and the server produces errors when casting to integer.

incorrect connection lines

Incorrect connection lines are being drawn when both Inbound and Outbound traffic are enabled. And some incorrect lines even when just Inbound is enabled.
Fix:

  1. Split database Links# tables for each direction into LinksIn# and LinksOut#. This is to because of the clustering in the links table
    1. Instead, have clustered links be: 172.-1.-1.-1?
  2. Ensure all links are preprocessed identically so any duplicate lines will overlap entirely.

Node size

A map node changes size under certain conditions when auto-refresh is enabled:
Zoom in on it.
Select it.
Wait for an auto-refresh tick.
Zoom out. The node changes size incorrectly.

Possible cause: selection holds onto an orphaned reference to the old node (that should have been replaced during refresh) This old reference doesn't have it's size updated correctly.

Solution: clear old selection and reselect new object after refresh.

abstract log importer

The import_* files are all very similar and contain duplicated code.
Rather than continue to duplicate code in many places, a standard interface or superclass should be built. In many cases merely overriding the translate(...) function will be sufficient to cover a new format.

Port Links break on table sort

When the ports tab of the selection-details panel is sorted by clicking on one of the column headers, the port tooltips and popup stop working.
Something in the tablesort plugin removes the event associations from the anchor element.

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.