├── shared └── .gitkeep ├── run.sh ├── public ├── favicon.ico ├── manifest.json └── index.html ├── demo_images ├── demo.png ├── demo2.png ├── demo3.png ├── demo_flag.png ├── cherry-blossom.png ├── demo_hex_dump.png ├── demp_export_pwn.png ├── demo_request_export.png ├── demo_search_hilight.png ├── demo_service_selection.png └── logo.svg ├── .babelrc ├── services ├── requirements.txt ├── test_pcap │ ├── starcalc.pcap │ └── dump-2018-06-27_13:25:31.pcap ├── run_ws.sh ├── ws_configuration │ ├── run.sh │ ├── setup_ws.sh │ ├── delete_old_and_move.py │ └── ws_pcap_importer.sh ├── ws_pcap_importer.sh ├── flow2pwn.py ├── configurations.py ├── .gitignore ├── README.md ├── webservice.py ├── tests.py ├── data2req.py ├── db.py └── importer.py ├── .flowconfig ├── Dockerfile-node ├── .circleci └── config.yml ├── Dockerfile-python ├── docker-compose.yml ├── src ├── index.css ├── components │ ├── Favourites.js │ ├── FileSelectionList.js │ ├── CopyModal.js │ ├── TimeSelectionList.js │ ├── ServiceSelector.js │ ├── FlowItem.js │ ├── FlowList.js │ ├── Toolbar.js │ └── FlowDetail.js ├── App.test.js ├── index.js ├── App.css ├── test_data │ └── dummy_data.js ├── data │ └── fetcher.js ├── registerServiceWorker.js ├── App.js └── logo.svg ├── package.json ├── .gitignore ├── README.md └── LICENSE /shared/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | npm start 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /demo_images/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo.png -------------------------------------------------------------------------------- /demo_images/demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo2.png -------------------------------------------------------------------------------- /demo_images/demo3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo3.png -------------------------------------------------------------------------------- /demo_images/demo_flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo_flag.png -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["flow", "react"], 3 | "plugins": ["transform-class-properties"] 4 | } 5 | -------------------------------------------------------------------------------- /services/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask_Cors==3.0.6 2 | pymongo==3.6.1 3 | Flask==1.0.2 4 | requests==2.23.0 5 | -------------------------------------------------------------------------------- /demo_images/cherry-blossom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/cherry-blossom.png -------------------------------------------------------------------------------- /demo_images/demo_hex_dump.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo_hex_dump.png -------------------------------------------------------------------------------- /demo_images/demp_export_pwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demp_export_pwn.png -------------------------------------------------------------------------------- /services/test_pcap/starcalc.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/services/test_pcap/starcalc.pcap -------------------------------------------------------------------------------- /demo_images/demo_request_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo_request_export.png -------------------------------------------------------------------------------- /demo_images/demo_search_hilight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo_search_hilight.png -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [lints] 8 | 9 | [options] 10 | 11 | [strict] 12 | -------------------------------------------------------------------------------- /demo_images/demo_service_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/demo_images/demo_service_selection.png -------------------------------------------------------------------------------- /services/test_pcap/dump-2018-06-27_13:25:31.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secgroup/flower/HEAD/services/test_pcap/dump-2018-06-27_13:25:31.pcap -------------------------------------------------------------------------------- /Dockerfile-node: -------------------------------------------------------------------------------- 1 | FROM node:10 2 | 3 | COPY . /app 4 | 5 | WORKDIR /app 6 | 7 | RUN rm -rf node_modules && \ 8 | yarn install && \ 9 | yarn build 10 | 11 | EXPOSE 3000 12 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/python:3.8 6 | steps: 7 | - checkout 8 | - setup_remote_docker 9 | - run: docker-compose up -d 10 | - run: sleep 60 11 | - run: docker exec -it project_flower-python_1 python2 services/tests.py 12 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Flower", 3 | "name": "CTF flow analyzer", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /Dockerfile-python: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY . /app 4 | 5 | WORKDIR /app 6 | 7 | RUN apt-get update && \ 8 | apt-get install -y tcpdump libnet1-dev libpcap-dev tar patch wget && \ 9 | wget "https://github.com/MITRECND/pynids/archive/0.6.2.tar.gz" && \ 10 | tar -xvzf 0.6.2.tar.gz && \ 11 | cd pynids-0.6.2/ && \ 12 | python setup.py build && \ 13 | python setup.py install && \ 14 | cd /app && \ 15 | pip install -r services/requirements.txt 16 | 17 | CMD sleep 3 && \ 18 | find services/test_pcap -name *.pcap -exec python services/importer.py {} \; && \ 19 | python services/webservice.py 20 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | services: 3 | 4 | mongo: 5 | image: mongo:4 6 | networks: 7 | - internal 8 | restart: always 9 | 10 | flower-node: 11 | build: 12 | context: . 13 | dockerfile: Dockerfile-node 14 | image: flower-node:latest 15 | ports: 16 | - "3000:3000" 17 | depends_on: 18 | - mongo 19 | networks: 20 | - internal 21 | command: "yarn start" 22 | environment: 23 | REACT_APP_FLOWER_MONGO: mongo 24 | REACT_APP_FLAG_REGEX: "FLG[0-9a-f]{29}" 25 | REACT_APP_FLOWER_SERVICES: 127.0.0.1 26 | 27 | flower-python: 28 | build: 29 | context: . 30 | dockerfile: Dockerfile-python 31 | image: flower-python:latest 32 | ports: 33 | - "5000:5000" 34 | depends_on: 35 | - mongo 36 | networks: 37 | - internal 38 | volumes: 39 | - ./shared:/shared 40 | environment: 41 | REACT_APP_FLOWER_MONGO: mongo 42 | REACT_APP_FLAG_REGEX: "FLG[0-9a-f]{29}" 43 | 44 | networks: 45 | internal: 46 | -------------------------------------------------------------------------------- /services/run_ws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #export FLASK_APP=webservice.py 3 | #python -m flask run --host=0.0.0.0 4 | 5 | # This file is part of Flower. 6 | # 7 | # Copyright ©2018 Nicolò Mazzucato 8 | # Copyright ©2018 Antonio Groza 9 | # Copyright ©2018 Brunello Simone 10 | # Copyright ©2018 Alessio Marotta 11 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12 | # 13 | # Flower is free software: you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation, either version 3 of the License, or 16 | # (at your option) any later version. 17 | # 18 | # Flower is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with Flower. If not, see . 25 | 26 | python webservice.py -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | body { 25 | margin: 0; 26 | padding: 0; 27 | font-family: sans-serif; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/components/Favourites.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | import React, { Component } from 'react'; 25 | 26 | export class Favourites extends Component { 27 | render() { 28 | return ( 29 |
30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | import React from 'react'; 25 | import ReactDOM from 'react-dom'; 26 | import App from './App'; 27 | 28 | it('renders without crashing', () => { 29 | const div = document.createElement('div'); 30 | ReactDOM.render(, div); 31 | ReactDOM.unmountComponentAtNode(div); 32 | }); 33 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | import React from 'react'; 25 | import ReactDOM from 'react-dom'; 26 | import './index.css'; 27 | import App from './App'; 28 | import registerServiceWorker from './registerServiceWorker'; 29 | 30 | 31 | ReactDOM.render(, document.getElementById('root')); 32 | registerServiceWorker(); 33 | -------------------------------------------------------------------------------- /services/ws_configuration/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This file is part of Flower. 4 | # 5 | # Copyright ©2018 Nicolò Mazzucato 6 | # Copyright ©2018 Antonio Groza 7 | # Copyright ©2018 Brunello Simone 8 | # Copyright ©2018 Alessio Marotta 9 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 | # 11 | # Flower is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Flower is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Flower. If not, see . 23 | 24 | vm_host="10.10.3.1" 25 | 26 | echo "setup server $vm_host" 27 | echo "coping delete_old_and_move" 28 | scp delete_old_and_move.py root@$vm_host:/root/pcap/delete_old_and_move.py 29 | echo "executing setup" 30 | ssh root@$vm_host 'bash -s' < ./setup_ws.sh 31 | 32 | echo "---> SETUP DONE!" 33 | 34 | #./ws_pcap_importer.sh -------------------------------------------------------------------------------- /services/ws_configuration/setup_ws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of Flower. 4 | # 5 | # Copyright ©2018 Nicolò Mazzucato 6 | # Copyright ©2018 Antonio Groza 7 | # Copyright ©2018 Brunello Simone 8 | # Copyright ©2018 Alessio Marotta 9 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 | # 11 | # Flower is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Flower is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Flower. If not, see . 23 | 24 | #questo script verrà eseguito sul server 25 | 26 | echo "setup from ws!" 27 | mkdir pcap 28 | cd pcap 29 | mkdir done 30 | 31 | apt -y install apparmor-utils 32 | aa-complain /usr/sbin/tcpdump 33 | echo "killing tcpdump" 34 | pkill -f tcpdump 35 | echo "executing tcpdump" 36 | tcpdump -G 60 -w dump-%Y-%m-%d_%H:%M:%S.pcap -z "/root/pcap/delete_old_and_move.py" port 80 or 5000 or 8080 or 9876 37 | 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flower", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^1.2.1", 7 | "@material-ui/icons": "^1.1.0", 8 | "arrow-keys-react": "^1.0.6", 9 | "dompurify": "^2.0.17", 10 | "escape-html": "^1.0.3", 11 | "flow-bin": "^0.74.0", 12 | "hexdump-nodejs": "^0.1.0", 13 | "lodash": "^4.17.19", 14 | "material-ui": "^1.0.0-beta.47", 15 | "material-ui-search-bar": "^1.0.0-beta.4", 16 | "moment": "^2.22.2", 17 | "react": "^16.4.1", 18 | "react-copy-to-clipboard": "^5.0.1", 19 | "react-dom": "^16.4.2", 20 | "react-moment": "^0.7.4", 21 | "react-scripts": "1.1.4", 22 | "react-split-pane": "^0.1.77", 23 | "react-time-range-picker": "^1.4.0", 24 | "react-tiny-virtual-list": "^2.1.4", 25 | "react-virtual-list": "^2.3.0", 26 | "react-virtualized": "^9.19.1" 27 | }, 28 | "scripts": { 29 | "start": "react-scripts start", 30 | "build": "babel src/ -d lib/", 31 | "test": "react-scripts test --env=jsdom", 32 | "eject": "react-scripts eject", 33 | "prepublish": "npm run build", 34 | "flow": "flow" 35 | }, 36 | "devDependencies": { 37 | "babel-cli": "^6.26.0", 38 | "babel-preset-flow": "^6.23.0", 39 | "prettier": "1.13.5", 40 | "babel-preset-react": "^6.24.1", 41 | "babel-plugin-transform-class-properties": "^6.24.1" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /services/ws_configuration/delete_old_and_move.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This file is part of Flower. 4 | # 5 | # Copyright ©2018 Nicolò Mazzucato 6 | # Copyright ©2018 Antonio Groza 7 | # Copyright ©2018 Brunello Simone 8 | # Copyright ©2018 Alessio Marotta 9 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 | # 11 | # Flower is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Flower is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Flower. If not, see . 23 | 24 | from sys import argv 25 | from time import sleep 26 | import os 27 | 28 | COUNT = 120 29 | DIRNAME = './done/' 30 | 31 | os.chdir(DIRNAME) 32 | files = os.listdir(".") 33 | 34 | if len(files) > COUNT: 35 | # assuming file name YYYY-MM-DD_HH:MM:SS.pcap 36 | oldest_file = sorted(files)[0] 37 | os.remove(oldest_file) 38 | 39 | to_rename= '../' + argv[1] 40 | print "to rename: ",to_rename 41 | 42 | os.rename('../' + argv[1], argv[1]) 43 | 44 | #usare latin1 testare con urandom -------------------------------------------------------------------------------- /services/ws_pcap_importer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of Flower. 4 | # 5 | # Copyright ©2018 Nicolò Mazzucato 6 | # Copyright ©2018 Antonio Groza 7 | # Copyright ©2018 Brunello Simone 8 | # Copyright ©2018 Alessio Marotta 9 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 | # 11 | # Flower is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Flower is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Flower. If not, see . 23 | 24 | #sul server deve essere eseguito: 25 | #cd ~/pcap_dumps 26 | #tcpdump -G 120 -w dump-%Y-%m-%d_%H:%M:%S.pcap -z "./delete_old_and_move.py" port 7789 or 5010 or 80 & 27 | #dove vanno messe le porte dei servizi 28 | 29 | importer_script_path='/mnt/DATA/cyberChallange/github/ctftools/flower-services/importer.py' 30 | import_path='/mnt/DATA/pcap_dumps' 31 | 32 | cd $import_path 33 | 34 | while true 35 | do 36 | rsync -avzh root@10.0.1.1:~/pcap/done $import_path 37 | ultimo=$(find ./done -type f -printf '%T@ %p\n' | sort | tail -1 | cut -f2- -d" ") 38 | python $importer_script_path $ultimo 39 | sleep 60 40 | done -------------------------------------------------------------------------------- /services/flow2pwn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | #convert a flow into pwn script 26 | def flow2pwn(flow): 27 | ip = flow["dst_ip"] 28 | port = flow["dst_port"] 29 | 30 | script = """from pwn import * 31 | 32 | proc = remote('{}', {}) 33 | """.format(ip, port) 34 | 35 | for message in flow['flow']: 36 | if message['from'] == 's': 37 | script += """proc.writeline("{}")\n""".format(message['data'][:-1]) 38 | 39 | else: 40 | for m in range(len(message['data'])): 41 | script += """proc.recvuntil("{}")\n""".format(message['data'][-20:].replace("\n","\\n")) 42 | break 43 | 44 | return script 45 | -------------------------------------------------------------------------------- /services/ws_configuration/ws_pcap_importer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of Flower. 4 | # 5 | # Copyright ©2018 Nicolò Mazzucato 6 | # Copyright ©2018 Antonio Groza 7 | # Copyright ©2018 Brunello Simone 8 | # Copyright ©2018 Alessio Marotta 9 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 | # 11 | # Flower is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Flower is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Flower. If not, see . 23 | 24 | #sul server deve essere eseguito: 25 | #cd ~/pcap_dumps 26 | #tcpdump -G 120 -w dump-%Y-%m-%d_%H:%M:%S.pcap -z "./delete_old_and_move.py" port 7789 or 5010 or 80 & 27 | #dove vanno messe le porte dei servizi 28 | 29 | importer_script_path='/mnt/DATA/cyberChallange/github/ctftools/flower-services/importer.py' 30 | import_path='/mnt/DATA/pcap_dumps' 31 | 32 | cd $import_path 33 | 34 | while true 35 | do 36 | rsync -avzh root@10.10.3.1:~/pcap/done $import_path 37 | ultimo=$(find ./done -type f -printf '%T@ %p\n' | sort | tail -1 | cut -f2- -d" ") 38 | echo "importing: " $ultimo 39 | python $importer_script_path $ultimo 40 | sleep 60 41 | done -------------------------------------------------------------------------------- /services/configurations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | import re 26 | import os 27 | 28 | ws_ip = os.getenv("REACT_APP_FLOWER_MONGO", "0.0.0.0") 29 | mongo_server = 'mongodb://' + ws_ip + ':27017/' 30 | vm_ip = "10.10.3.1" # todo put regex 31 | 32 | services = [{"ip": vm_ip, "port": 9876, "name": "cc_market"}, 33 | {"ip": vm_ip, "port": 80, "name": "maze"}, 34 | {"ip": vm_ip, "port": 8080, "name": "scadent"}, 35 | {"ip": vm_ip, "port": 5000, "name": "starchaser"}, 36 | {"ip": vm_ip, "port": 1883, "name": "scadnet_bin"}] 37 | 38 | 39 | def containsFlag(text): 40 | # todo implementare logica contains 41 | regex_flag = os.getenv("REACT_APP_FLAG_REGEX", r'[A-Z0-9]{31}=') 42 | match = re.match(regex_flag, text) 43 | return match 44 | -------------------------------------------------------------------------------- /services/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | workspace.xml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | 24 | #PYTHON 25 | 26 | # Byte-compiled / optimized / DLL files 27 | __pycache__/ 28 | *.py[cod] 29 | *$py.class 30 | 31 | # C extensions 32 | *.so 33 | 34 | # Distribution / packaging 35 | .Python 36 | build/ 37 | develop-eggs/ 38 | dist/ 39 | downloads/ 40 | eggs/ 41 | .eggs/ 42 | lib/ 43 | lib64/ 44 | parts/ 45 | sdist/ 46 | var/ 47 | wheels/ 48 | *.egg-info/ 49 | .installed.cfg 50 | *.egg 51 | MANIFEST 52 | 53 | # PyInstaller 54 | # Usually these files are written by a python script from a template 55 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 56 | *.manifest 57 | *.spec 58 | 59 | # Installer logs 60 | pip-log.txt 61 | pip-delete-this-directory.txt 62 | 63 | # Unit test / coverage reports 64 | htmlcov/ 65 | .tox/ 66 | .coverage 67 | .coverage.* 68 | .cache 69 | nosetests.xml 70 | coverage.xml 71 | *.cover 72 | .hypothesis/ 73 | .pytest_cache/ 74 | 75 | # Translations 76 | *.mo 77 | *.pot 78 | 79 | # Django stuff: 80 | *.log 81 | local_settings.py 82 | db.sqlite3 83 | 84 | # Flask stuff: 85 | instance/ 86 | .webassets-cache 87 | 88 | # Scrapy stuff: 89 | .scrapy 90 | 91 | # Sphinx documentation 92 | docs/_build/ 93 | 94 | # PyBuilder 95 | target/ 96 | 97 | # Jupyter Notebook 98 | .ipynb_checkpoints 99 | 100 | # pyenv 101 | .python-version 102 | 103 | # celery beat schedule file 104 | celerybeat-schedule 105 | 106 | # SageMath parsed files 107 | *.sage.py 108 | 109 | # Environments 110 | .env 111 | .venv 112 | env/ 113 | venv/ 114 | ENV/ 115 | env.bak/ 116 | venv.bak/ 117 | 118 | # Spyder project settings 119 | .spyderproject 120 | .spyproject 121 | 122 | # Rope project settings 123 | .ropeproject 124 | 125 | # mkdocs documentation 126 | /site 127 | 128 | # mypy 129 | .mypy_cache/ 130 | 131 | workspace.xml -------------------------------------------------------------------------------- /services/README.md: -------------------------------------------------------------------------------- 1 | # Services 2 | 3 | 4 | 5 | ### General idea 6 | We create pcap of N minutes on the virtual machine. We somehow download them, and use the `importer.py` script to analyze and import them into mongodb. The webapp does rest request to the webservices, that does query to mongodb. 7 | 8 | 9 | ### MongoDB structure 10 | We use a single collection for all the pcaps 11 | Each document will have: 12 | ```{ 13 | "inx": //progressive flow index inside pcap 14 | "time": //start timestamp 15 | "duration": //end_time-start_time 16 | "src_ip": "127.0.0.1", 17 | "src_port": 1234 , 18 | "dst_ip": "127.0.0.1", 19 | "dst_port": 1234, 20 | "contains_flag": //true if the importer have found that the flow contains a flag based on the env var regex 21 | "starred": //if the flow is starred 22 | "flow": [ 23 | { 24 | "data": "...", //printable data 25 | "hex": //original data encoded in hex 26 | "from": "c" // "c" for client, "s" for server 27 | "time": //timestamp 28 | }, 29 | ... 30 | ], 31 | 32 | } 33 | 34 | ``` 35 | 36 | # Services description 37 | All the end-points return an object or an array of objects. 38 | 39 | ##### POST /query 40 | Accept the following payload 41 | ``` 42 | { 43 | flow.data: "regex on data field of flow", 44 | dst_ip: "1.2.3.4" 45 | dst_port: "1.2.3.4" 46 | time : {"$gte": from_millis, 47 | "$lt": to_millis} 48 | } 49 | 50 | ``` 51 | It returns an array of documents, WITHOUT the "flow" field 52 | 53 | ##### GET /services 54 | Returns informations about all services. It is configurable on `configurations.py` 55 | 56 | ##### GET /flow/(flow_id) 57 | Returns the all document with `flow_id` id, including the field `flow` 58 | 59 | ##### GET /star/(flow_id)/(0,1) 60 | Set the flow favourite (1) or not (0) 61 | 62 | ##### POST /starred 63 | Returns a list of document like `/query` endpoint, but only with starred items. 64 | 65 | ##### POST /to_python_request/(tokenize) 66 | convert the request to python syntax. Tokenize is used to toggle the auto-parsing of args. 67 | 68 | ##### GET /to_pwn/(id) 69 | Convert the flow with the specified id in pwntools syntax 70 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 44 | Flower 45 | 46 | 47 | 50 |
51 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | .App { 25 | text-align: center; 26 | } 27 | 28 | .App-logo { 29 | animation: App-logo-spin infinite 20s linear; 30 | height: 80px; 31 | } 32 | 33 | .App-header { 34 | background-color: #222; 35 | height: 150px; 36 | padding: 20px; 37 | color: white; 38 | } 39 | 40 | .App-title { 41 | font-size: 1.5em; 42 | } 43 | 44 | .App-intro { 45 | font-size: large; 46 | } 47 | 48 | @keyframes App-logo-spin { 49 | from { 50 | transform: rotate(0deg); 51 | } 52 | to { 53 | transform: rotate(360deg); 54 | } 55 | } 56 | 57 | .rows .row { 58 | display: inline-block; 59 | } 60 | @import url("https://fonts.googleapis.com/css?family=Roboto+Mono"); 61 | 62 | .column_4_small { 63 | float: left; 64 | top: 0px; 65 | bottom: 0px; 66 | width: 15%; 67 | height: 100vh; 68 | padding: 1px; 69 | margin: 10px; 70 | } 71 | .column_4_big { 72 | float: left; 73 | top: 0px; 74 | bottom: 0px; 75 | width: 30%; 76 | height: 100vh; 77 | padding: 1px; 78 | margin: 10px; 79 | } 80 | .column_2 { 81 | float: left; 82 | top: 0px; 83 | bottom: 0px; 84 | width: 50%; 85 | height: 100vh; 86 | padding: 1px; 87 | margin: 10px; 88 | } 89 | .row:after { 90 | content: ""; 91 | display: table; 92 | clear: both; 93 | } 94 | 95 | #fav_flow { 96 | width: 96px; 97 | height: 200px; 98 | padding: 2px; 99 | border: 1px solid #000; 100 | float: left; 101 | background-color: #f00; 102 | } 103 | 104 | #all_flow { 105 | width: 96px; 106 | padding: 2px; 107 | height: 100%; 108 | border: 1px solid #000; 109 | float: right; 110 | background-color: #f00; 111 | } 112 | 113 | #flow_details { 114 | padding: 2px; 115 | 116 | height: 100%; 117 | margin-left: 105px; 118 | border: 1px solid #000; 119 | background-color: #090; 120 | } 121 | -------------------------------------------------------------------------------- /services/webservice.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | from flask import Flask, Response 26 | 27 | from configurations import services 28 | from data2req import convert_http_requests 29 | from db import DB 30 | from bson import json_util 31 | from flask_cors import CORS 32 | from flask import request 33 | 34 | from flow2pwn import flow2pwn 35 | 36 | application = Flask(__name__) 37 | CORS(application) 38 | db = DB() 39 | 40 | 41 | def return_response(object): 42 | return Response(json_util.dumps(object), mimetype='applicationlication/json') 43 | 44 | 45 | @application.route('/') 46 | def hello_world(): 47 | return 'Hello, World!' 48 | 49 | 50 | @application.route('/query', methods=['POST']) 51 | def query(): 52 | json = request.get_json() 53 | result = db.getFlowList(json) 54 | return return_response(result) 55 | 56 | 57 | @application.route('/starred', methods=['POST']) 58 | def getStarred(): 59 | json = request.get_json() 60 | json["starred"] = 1 61 | result = db.getFlowList(json) 62 | return return_response(result) 63 | 64 | 65 | 66 | 67 | @application.route('/star//') 68 | def setStar(flow_id, star_to_set): 69 | db.setStar(flow_id, star_to_set) 70 | return "ok!" 71 | 72 | 73 | @application.route('/services') 74 | def getServices(): 75 | return return_response(services) 76 | 77 | 78 | @application.route('/flow/') 79 | def getFlowDetail(id): 80 | to_ret = return_response(db.getFlowDetail(id)) 81 | return to_ret 82 | 83 | 84 | @application.route('/to_python_request/', methods=['POST']) 85 | def convertToRequests(tokenize): 86 | data = request.data 87 | converted = convert_http_requests(data,True if tokenize == "true" else False) 88 | return converted 89 | 90 | @application.route('/to_pwn/') 91 | def confertToPwn(id): 92 | flow = db.getFlowDetail(id) 93 | converted = flow2pwn(flow) 94 | return converted 95 | 96 | if __name__ == "__main__": 97 | application.run(host='0.0.0.0',threaded=True) 98 | 99 | -------------------------------------------------------------------------------- /src/components/FileSelectionList.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | 28 | import { withStyles } from "@material-ui/core/styles"; 29 | import List from "@material-ui/core/List"; 30 | import ListItem from "@material-ui/core/ListItem"; 31 | import ListItemIcon from "@material-ui/core/ListItemIcon"; 32 | import ListItemText from "@material-ui/core/ListItemText"; 33 | import Divider from "@material-ui/core/Divider"; 34 | import { fetchFiles } from "../data/fetcher"; 35 | 36 | const styles = theme => ({ 37 | root: { 38 | width: "100%", 39 | backgroundColor: theme.palette.background.paper 40 | } 41 | }); 42 | 43 | export class FileSelectionList extends Component<{ 44 | file_clicked: Function, 45 | items: Array<{ id: string, name: string }>, 46 | actual_inx: Number 47 | }> { 48 | constructor(props) { 49 | super(props); 50 | this.state = { files: [], actual_inx: -1 }; 51 | } 52 | componentDidMount() { 53 | fetchFiles(files => { 54 | console.log("ok, ho i files: "); 55 | console.log(files); 56 | this.setState({ files: files }); 57 | if (this.state.actual_inx == -1 && files.length > 0) { 58 | this.props.file_clicked(files[0]); 59 | this.setState({ actual_inx: 0 }); 60 | } 61 | }); 62 | } 63 | render() { 64 | var items = this.state.files || []; 65 | var actual_inx = this.state.actual_inx; 66 | return ( 67 | 68 | {items.map((item, inx) => ( 69 | { 72 | this.props.file_clicked(item); 73 | this.setState({ actual_inx: inx }); 74 | }} 75 | style={{ 76 | backgroundColor: inx == actual_inx ? "#00B1E1" : "#FFFFFF" 77 | }} 78 | button 79 | > 80 | 81 | 82 | ))} 83 | 84 | ); 85 | } 86 | } 87 | export default withStyles(styles)(FileSelectionList); 88 | -------------------------------------------------------------------------------- /src/test_data/dummy_data.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | export default { 25 | dummy_flows: [ 26 | { 27 | id: "1", 28 | src: "127.0.0.1:45384", 29 | dst: "127.0.0.1:4003", 30 | data: [ 31 | { 32 | data: 33 | "GET /mmm HTTP/1.1\r\nHost: localhost:4003\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.18.4\r\n\r\n", 34 | actor: "server" 35 | }, 36 | { 37 | data: 38 | "HTTP/1.0 500 Internal Server Error\r\nServer: BaseHTTP/0.6 Python/3.6.5\r\nDate: Wed, 13 Jun 2018 22:54:28 GMT\r\nContent-type: text/html\r\n\r\n", 39 | actor: "client" 40 | }, 41 | { 42 | data: "nope", 43 | actor: "client" 44 | } 45 | ] 46 | }, 47 | { 48 | id: "2", 49 | src: "127.0.0.1:47098", 50 | dst: "127.0.0.1:4005", 51 | data: [ 52 | { 53 | data: 54 | "GET /mmm HTTP/1.1\r\nHost: localhost:4005\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.18.4\r\n\r\n", 55 | actor: "server" 56 | }, 57 | { 58 | data: 59 | "HTTP/1.0 500 Internal Server Error\r\nServer: BaseHTTP/0.6 Python/3.6.5\r\nDate: Wed, 13 Jun 2018 22:54:28 GMT\r\nContent-type: text/html\r\n\r\n", 60 | actor: "client" 61 | }, 62 | { 63 | data: "nope", 64 | actor: "client" 65 | } 66 | ] 67 | }, 68 | { 69 | id: "3", 70 | src: "127.0.0.1:50226", 71 | dst: "127.0.0.1:4001", 72 | data: [ 73 | { 74 | data: 75 | "GET /mmm HTTP/1.1\r\nHost: localhost:4002\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.18.4\r\n\r\n", 76 | actor: "server" 77 | } 78 | ] 79 | } 80 | ] 81 | }; 82 | -------------------------------------------------------------------------------- /services/tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | # I assume only services/test_pcap.pacp has been imported 25 | 26 | import requests 27 | import base64 28 | import binascii 29 | 30 | #WS_URL = "http://localhost:5000" 31 | #FE_URL = "http://localhost:3000" 32 | 33 | WS_URL = "http://flower-python:5000" 34 | FE_URL = "http://flower-node:3000" 35 | 36 | def get_first_flow_id(): 37 | res = requests.post("{}/query".format(WS_URL), json={}).json() 38 | return res[0]["_id"]["$oid"] 39 | 40 | FLOW_ID = get_first_flow_id() 41 | 42 | def do_request(path): 43 | return requests.get("{}/{}".format(WS_URL,path)) 44 | 45 | def get_starred(): 46 | return requests.post("{}/starred".format(WS_URL), json={}).json() 47 | 48 | def test_services(): 49 | services = do_request("services").json() 50 | assert len(services) == 5 51 | assert services[0]["ip"] == "10.10.3.1" 52 | 53 | def test_query(): 54 | res = requests.post("{}/query".format(WS_URL), json={}).json() 55 | assert len(res) == 539 56 | 57 | def test_star(): 58 | assert len(get_starred()) == 0 59 | requests.get("{}/star/{}/1".format(WS_URL,FLOW_ID)) 60 | assert len(get_starred()) == 1 61 | requests.get("{}/star/{}/0".format(WS_URL,FLOW_ID)) 62 | assert len(get_starred()) == 0 63 | 64 | def test_frontend(): 65 | assert "You need to enable JavaScript to run this app." in requests.get("{}".format(FE_URL)).text 66 | # todo find a better way to test this, maybe 67 | 68 | def test_flow(): 69 | flow = requests.get("{}/flow/{}".format(WS_URL,FLOW_ID)).json() 70 | assert len(flow["flow"]) == 70 71 | # non-printable char are replaced with other things, so we check only the first 72 | for p in flow["flow"][:1]: 73 | assert binascii.hexlify(p['data'].encode('ascii')).decode('ascii') == p["hex"] 74 | 75 | assert flow["src_port"] == 38910 76 | assert flow["dst_port"] == 9876 77 | assert flow["src_ip"] == "10.10.3.126" 78 | assert flow["dst_ip"] == "10.10.3.1" 79 | assert flow["time"] == 1530098790268 80 | assert flow["duration"] == 457 81 | 82 | def test_convert_to_request(): 83 | # todo 84 | pass 85 | 86 | def test_convert_to_pwntools(): 87 | # todo 88 | pass 89 | 90 | def main(): 91 | test_services() 92 | test_query() 93 | test_star() 94 | test_frontend() 95 | test_flow() 96 | 97 | if __name__ == "__main__": 98 | main() 99 | -------------------------------------------------------------------------------- /services/data2req.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | import pprint 26 | 27 | try: 28 | from BaseHTTPServer import BaseHTTPRequestHandler 29 | from StringIO import StringIO 30 | except ImportError: 31 | # python3 32 | from http.server import BaseHTTPRequestHandler 33 | from io import StringIO 34 | 35 | #class to parse request informations 36 | class HTTPRequest(BaseHTTPRequestHandler): 37 | def __init__(self, request_text): 38 | self.rfile = StringIO(request_text) 39 | self.raw_requestline = self.rfile.readline() 40 | self.error_code = self.error_message = None 41 | self.parse_request() 42 | 43 | def send_error(self, code, message): 44 | self.error_code = code 45 | self.error_message = message 46 | 47 | # tokenize used for automatically fill data param of request 48 | def convert_http_requests(data, tokenize=True): 49 | request = HTTPRequest(data) 50 | body = data.split("\n\n", 1) 51 | 52 | tokens = {} 53 | headers = {} 54 | 55 | if tokenize and len(body) > 1: 56 | for i in body[1].split("&"): 57 | d = i.split("=") 58 | tokens[d[0]] = d[1] 59 | 60 | blocked_headers = ["content-length", "accept-encoding", "connection", "accept"] 61 | 62 | for i in request.headers: 63 | if not i in blocked_headers: 64 | headers[i] = request.headers[i] 65 | 66 | return """requests.{}("http://"+sys.argv[1]+"{}",\n\tdata={},\n\theaders={}\n)""".format( 67 | request.command.lower(), 68 | request.path, 69 | tokens, 70 | str(dict(headers)), 71 | ) 72 | 73 | 74 | 75 | 76 | test_data = """GET /messages HTTP/1.1 77 | User-Agent: Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.8 Safari/534.34 78 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 79 | Cookie: session=.eJwdjsFqwzAQBX-l7DkULEcXQ6EHucGHXZMgW0iX0NhOXMlKQG5QrZB_r9vjg5nhPeB4DsM8QvEd7sMGjl89FA94OUEBJFpXS2ONLCMJx1A0kRhynfCnliXT_jCRpdHIC0PWWrKTJ4lRq32qVclRVAvJMmFq-OrlpJCtbDRCs1o1SdsmQ9l6s9tz3GEi1fpadFta919XW-PJVzmmbtEWOcmPkWSVa-syTHoxtkzkdWaEe4PnBu7zEP7_wzj769KncIm8f8_c-XPqbtfXMJzg-QtOmlBt.DhJ0zQ.EgQaH_4t3viAFoeSsir_tVxdBDo 80 | Connection: Keep-Alive 81 | Accept-Encoding: gzip 82 | Accept-Language: en-US,* 83 | Host: 10.0.1.1:5010""" 84 | 85 | if __name__ == "__main__": 86 | print(convert_http_requests(data, False)) 87 | -------------------------------------------------------------------------------- /src/components/CopyModal.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React from "react"; 27 | import PropTypes from "prop-types"; 28 | import { withStyles } from "@material-ui/core/styles"; 29 | import Typography from "@material-ui/core/Typography"; 30 | import Modal from "@material-ui/core/Modal"; 31 | import { CopyToClipboard } from "react-copy-to-clipboard"; 32 | 33 | function rand() { 34 | return Math.round(Math.random() * 20) - 10; 35 | } 36 | 37 | function getModalStyle() { 38 | const top = 50 + rand(); 39 | const left = 50 + rand(); 40 | 41 | return { 42 | top: `${top}%`, 43 | left: `${left}%`, 44 | transform: `translate(-${top}%, -${left}%)` 45 | }; 46 | } 47 | 48 | const styles = theme => ({ 49 | paper: { 50 | position: "absolute", 51 | backgroundColor: theme.palette.background.paper, 52 | width: 900, 53 | height: 700, 54 | overflow: "auto", 55 | whiteSpace: "pre-line", 56 | wordWrap: "break-word", 57 | boxShadow: theme.shadows[5], 58 | padding: theme.spacing.unit * 4 59 | } 60 | }); 61 | 62 | class CopyModal extends React.Component<{ 63 | classes: *, 64 | isOpen: boolean, 65 | onClose: () => *, 66 | text_to_copy: string, 67 | onCopy: string => void 68 | }> { 69 | render() { 70 | const { classes } = this.props; 71 | 72 | return ( 73 |
74 | 80 |
81 | 82 | Request to copy 83 | 84 |
{this.props.text_to_copy}
85 | 86 | 87 | 88 | 89 | 90 |
91 |
92 |
93 | ); 94 | } 95 | } 96 | 97 | CopyModal.propTypes = { 98 | classes: PropTypes.object.isRequired 99 | }; 100 | 101 | // We need an intermediary variable for handling the recursive nesting. 102 | const SimpleModalWrapped = withStyles(styles)(CopyModal); 103 | 104 | export default SimpleModalWrapped; 105 | -------------------------------------------------------------------------------- /services/db.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | import re 26 | 27 | from bson import ObjectId 28 | from pymongo import MongoClient 29 | from pymongo.errors import ServerSelectionTimeoutError 30 | import sys 31 | import pprint 32 | from configurations import mongo_server 33 | 34 | 35 | class DB: 36 | def __init__(self): 37 | try: 38 | self.client = MongoClient( 39 | mongo_server, serverSelectionTimeoutMS=200) 40 | self.client.server_info() 41 | self.db = self.client.pcap 42 | self.pcap_coll = self.db.pcap 43 | self.file_coll = self.db.filesImported 44 | 45 | except ServerSelectionTimeoutError as err: 46 | sys.stderr.write("MongoDB server not active on %s\n%s" % (mongo_server,err)) 47 | sys.exit(1) 48 | 49 | def getFlowList(self, filters): 50 | #print("parametri iniziali: ") 51 | #pprint.pprint(filters) 52 | f = {} 53 | if "flow.data" in filters: 54 | f["flow.data"] = re.compile(filters["flow.data"], re.IGNORECASE) 55 | if "dst_ip" in filters: 56 | f["dst_ip"] = filters["dst_ip"] 57 | if "dst_port" in filters: 58 | f["dst_port"] = int(filters["dst_port"]) 59 | if "from_time" in filters and "to_time" in filters: 60 | f["time"] = {"$gte": int(filters["from_time"]), 61 | "$lt": int(filters["to_time"])} 62 | if "starred" in filters: 63 | f["starred"] = filters["starred"] 64 | 65 | print("query:") 66 | pprint.pprint(f) 67 | 68 | return self.pcap_coll.find(f, {"flow": 0}).sort("time", -1).limit(2000) 69 | 70 | def getFlowDetail(self, id): 71 | return self.pcap_coll.find_one({"_id": ObjectId(id)}) 72 | 73 | def setStar(self, flow_id, star): 74 | self.pcap_coll.find_one_and_update({"_id": ObjectId(flow_id)}, {"$set": {"starred": 1 if star == '1' else 0}}) 75 | 76 | def isFileAlreadyImported(self, file_name): 77 | return self.file_coll.find({"file_name": file_name}).count() != 0 78 | 79 | def setFileImported(self, file_name): 80 | return self.file_coll.insert({"file_name": file_name}) 81 | 82 | def insertFlows(self, filename, flows): 83 | if self.isFileAlreadyImported(filename): 84 | print("file already present! not importing it!") 85 | return 86 | result = self.pcap_coll.insert_many(flows) 87 | print("result: ", result) 88 | #IMPORTANT! create index for each field in the table if not present before 89 | # col.create_index([("time", ASCENDING)]) 90 | # col.create_index([('flow.data', 'text')]) 91 | return result 92 | 93 | def delete_all_pcaps(self, filename): 94 | return self.pcap_coll.remove({}) 95 | -------------------------------------------------------------------------------- /src/components/TimeSelectionList.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | 28 | import { withStyles } from "@material-ui/core/styles"; 29 | import List from "@material-ui/core/List"; 30 | import ListItem from "@material-ui/core/ListItem"; 31 | import ListItemIcon from "@material-ui/core/ListItemIcon"; 32 | import ListItemText from "@material-ui/core/ListItemText"; 33 | import Divider from "@material-ui/core/Divider"; 34 | 35 | //utility 36 | import { fetchFiles } from "../data/fetcher"; 37 | import TimeRangePicker from "react-time-range-picker"; 38 | import moment from "moment"; 39 | 40 | const styles = theme => ({ 41 | root: { 42 | width: "100%", 43 | backgroundColor: theme.palette.background.paper 44 | } 45 | }); 46 | 47 | type props_types = { 48 | file_clicked: Function, 49 | items: Array<{ id: string, name: string }>, 50 | actual_inx: Number 51 | }; 52 | type state_types = { 53 | files: Array, 54 | actual_inx: number 55 | }; 56 | 57 | //@deprecated 58 | export class TimeSelectionList extends Component { 59 | constructor(props: props_types) { 60 | super(props); 61 | this.state = { files: [], actual_inx: -1 }; 62 | } 63 | pickerupdate = (start_time: string, end_time: string) => { 64 | // start and end time in 24hour time 65 | console.log(`start time: ${start_time}, end time: ${end_time}`); 66 | }; 67 | 68 | render() { 69 | console.log("time interval: " + this.props.timeInterval); 70 | var items = []; 71 | var five_min = 1000 * 60 * 5; 72 | var current_millis = new Date().getTime(); 73 | var current_millis_rounded = 74 | current_millis - (current_millis % five_min) + five_min; 75 | const intervals = this.props.timeInterval * 1000 * 60; 76 | for (var i = 0; i < 100; i++) 77 | items.push(current_millis_rounded - intervals * i); 78 | 79 | return ( 80 | 81 | {items.map((item, inx) => ( 82 | { 85 | this.props.setTimeWindow(item - intervals, item); 86 | this.setState({ actual_inx: inx }); 87 | }} 88 | style={{ 89 | backgroundColor: 90 | inx == this.state.actual_inx ? "#00B1E1" : "#FFFFFF" 91 | }} 92 | button 93 | > 94 | 101 | 102 | ))} 103 | 104 | ); 105 | } 106 | } 107 | export default withStyles(styles)(TimeSelectionList); 108 | -------------------------------------------------------------------------------- /src/data/fetcher.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | //@flow 25 | 26 | const server_ip = process.env.REACT_APP_FLOWER_SERVICES || "127.0.0.1"; 27 | const base_url = "http://" + server_ip + ":5000/"; 28 | 29 | export function fetchFlows(filters: *, then: (*) => mixed) { 30 | var filter_object = {}; 31 | 32 | if (hasNotEmpty(filters, "text_filter")) 33 | filter_object["flow.data"] = filters["text_filter"]; 34 | 35 | if (hasNotEmpty(filters, "dst_ip") && hasNotEmpty(filters, "dst_port")) { 36 | filter_object["dst_ip"] = filters["dst_ip"]; 37 | filter_object["dst_port"] = filters["dst_port"]; 38 | } 39 | if (hasNotEmpty(filters, "from_time") && hasNotEmpty(filters, "to_time")) { 40 | filter_object["from_time"] = filters["from_time"]; 41 | filter_object["to_time"] = filters["to_time"]; 42 | } 43 | if (hasNotEmpty(filters, "starred")) 44 | filter_object["starred"] = filters["starred"]; 45 | 46 | console.log("Fetching flows: "); 47 | console.log(filter_object); 48 | 49 | fetch(base_url + "query", { 50 | method: "POST", 51 | headers: { 52 | Accept: "application/json", 53 | "Content-Type": "application/json" 54 | }, 55 | body: JSON.stringify(filter_object) 56 | }) 57 | .then(response => { 58 | console.log(response); 59 | return response.json(); 60 | }) 61 | .then(responseJson => { 62 | then(responseJson); 63 | }) 64 | .catch(error => { 65 | console.log("errore con ws"); 66 | console.error(error); 67 | }); 68 | } 69 | 70 | export function fetchServices(then: (*) => mixed) { 71 | console.log("FETCHING services!!"); 72 | return fetchUrl(base_url + "services", data => then(data.sort())); 73 | } 74 | 75 | export function fetchFiles(then: (*) => mixed) { 76 | return fetchUrl(base_url + "files", data => then(data.sort().reverse())); 77 | } 78 | function hasNotEmpty(object, key) { 79 | return object && key in object && object[key]; 80 | } 81 | 82 | export function fetchFlow(flow_id: string, then: (*) => mixed) { 83 | var url = base_url + "flow/" + flow_id; 84 | return fetchUrl(url, then); 85 | } 86 | 87 | function fetchUrl(url, then) { 88 | return fetch(url) 89 | .then(response => response.json()) 90 | .then(responseJson => { 91 | then(responseJson); 92 | }) 93 | .catch(error => { 94 | console.log("errore con ws"); 95 | console.error(error); 96 | }); 97 | } 98 | 99 | export function setStarred(flow_id: string, star: boolean) { 100 | fetch(base_url + "star/" + flow_id + "/" + (star ? 1 : 0)); 101 | } 102 | 103 | export function getPythonRequest(request: string, then: (*) => mixed) { 104 | fetch(base_url + "to_python_request/1", { 105 | method: "POST", 106 | body: request 107 | }) 108 | .then(response => { 109 | console.log(response); 110 | return response.text(); 111 | }) 112 | .then(responseText => { 113 | then(responseText); 114 | }); 115 | } 116 | export function getPwnRequest(flow_id: string, then: (*) => mixed) { 117 | fetch(base_url + "to_pwn/" + flow_id) 118 | .then(response => { 119 | console.log(response); 120 | return response.text(); 121 | }) 122 | .then(responseText => { 123 | then(responseText); 124 | }); 125 | } 126 | -------------------------------------------------------------------------------- /src/components/ServiceSelector.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | 28 | //ui 29 | import { withStyles } from "@material-ui/core/styles"; 30 | import InputLabel from "@material-ui/core/InputLabel"; 31 | import MenuItem from "@material-ui/core/MenuItem"; 32 | import FormControl from "@material-ui/core/FormControl"; 33 | import Select from "@material-ui/core/Select"; 34 | 35 | import { fetchServices } from "../data/fetcher"; 36 | 37 | const styles = theme => ({ 38 | root: { 39 | display: "flex", 40 | flexWrap: "wrap" 41 | }, 42 | formControl: { 43 | margin: 0, 44 | padding: 2, 45 | minWidth: 120 46 | }, 47 | selectEmpty: { 48 | marginTop: theme.spacing.unit * 2 49 | } 50 | }); 51 | //{ip: "127.0.0.1", port: 80, name: "first service"} 52 | type Service_type={ 53 | ip: string, 54 | port: number, 55 | name: string 56 | }; 57 | type props_types = { 58 | onServicesFetched: (Array)=>void, 59 | classes:* 60 | }; 61 | type state_types={ 62 | services : Array, 63 | target_name: string 64 | }; 65 | export class ServiceSelector extends Component { 66 | constructor(props:props_types) { 67 | super(props); 68 | this.state = { 69 | services: [], 70 | target_name: "All" 71 | }; 72 | } 73 | componentDidMount() { 74 | fetchServices(services => { 75 | console.log("ok, ho i servizi: "); 76 | console.log(services); 77 | this.setState({ services: services }); 78 | this.props.onServicesFetched(services) 79 | }); 80 | } 81 | render() { 82 | const { classes } = this.props; 83 | console.log("nome che dovriei mettere: " + this.state.target_name); 84 | return ( 85 |
86 | 87 | Service 88 | 106 | 107 |
108 | ); 109 | } 110 | handleChange = event => { 111 | this.setState({ [event.target.name]: event.target.value }); 112 | 113 | var inx = event.target.value; 114 | if (inx === -1) this.props.onTargetChanged(null); 115 | else { 116 | var target_service = this.state.services[inx]; 117 | console.log("target service:") 118 | console.log(target_service ); 119 | this.props.onTargetChanged(target_service.ip,target_service.port); 120 | } 121 | }; 122 | } 123 | export default withStyles(styles)(ServiceSelector); 124 | -------------------------------------------------------------------------------- /services/importer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is part of Flower. 5 | # 6 | # Copyright ©2018 Nicolò Mazzucato 7 | # Copyright ©2018 Antonio Groza 8 | # Copyright ©2018 Brunello Simone 9 | # Copyright ©2018 Alessio Marotta 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11 | # 12 | # Flower is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # Flower is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with Flower. If not, see . 24 | 25 | #Script that import pcap into flower dg 26 | import json 27 | import nids #good luck installing pynids! 28 | import sys 29 | import string 30 | import pprint 31 | import time 32 | 33 | from configurations import containsFlag 34 | from db import DB 35 | 36 | end_states = (nids.NIDS_CLOSE, nids.NIDS_TIMEOUT, nids.NIDS_RESET) 37 | db = DB() 38 | 39 | data_flow = {} 40 | filename = "" 41 | flows_to_import = [] 42 | ts = {} 43 | contains_flag = {} 44 | done = 0 45 | start_time = {} 46 | inx = 0 47 | 48 | 49 | def handleTcpStream(tcp): 50 | global data_flow, ts, contains_flag, done, start_time, inx 51 | 52 | if tcp.nids_state == nids.NIDS_JUST_EST: 53 | tcp.client.collect = 1 54 | tcp.server.collect = 1 55 | data_flow[tcp.addr] = [] 56 | start_time[tcp.addr] = int(float(nids.get_pkt_ts()) * 1000) 57 | contains_flag[tcp.addr] = False 58 | elif tcp.nids_state == nids.NIDS_DATA: 59 | actor = tcp.client if tcp.client.count_new > 0 else tcp.server 60 | 61 | cnt = actor.count_new 62 | data = actor.data[:cnt] 63 | printable_data = ''.join([i if i in string.printable else '\\x{:02x}'.format(ord(i)) for i in data]) 64 | name = "c" if actor is tcp.client else "s" 65 | 66 | last_flow = (data_flow[tcp.addr] or [None])[-1] 67 | #this is from server, and last one is from server. Just concatenate data 68 | if last_flow and last_flow["from"] == name: 69 | data_flow[tcp.addr][-1]["data"] += printable_data 70 | data_flow[tcp.addr][-1]["hex"] += data.encode("hex") 71 | else: 72 | data_flow[tcp.addr].append( 73 | {"from": name, 74 | "data": printable_data, 75 | "hex": data.encode("hex"), 76 | "time": int(float(nids.get_pkt_ts()) * 1000) 77 | } 78 | ) 79 | #only if this we don't know if this flow contains a flag 80 | if not contains_flag[tcp.addr] and containsFlag(data): 81 | contains_flag[tcp.addr] = True 82 | 83 | tcp.discard(actor.count_new) 84 | 85 | elif tcp.nids_state in end_states: 86 | ((src, sport), (dst, dport)) = tcp.addr 87 | 88 | done += 1 89 | if done % 100 == 0: print(done) 90 | if len(data_flow[tcp.addr]) == 0: 91 | return 92 | 93 | ts = int(float(nids.get_pkt_ts()) * 1000) 94 | 95 | flow = {"inx": inx, 96 | "filename": filename, 97 | "src_ip": src, 98 | "src_port": sport, 99 | "dst_ip": dst, 100 | "dst_port": dport, 101 | "time": start_time[tcp.addr], 102 | "duration": (ts - start_time[tcp.addr]), 103 | "contains_flag": contains_flag[tcp.addr], 104 | "starred": 0, 105 | "flow": data_flow[tcp.addr] 106 | } 107 | 108 | flows_to_import.append(flow) 109 | del data_flow[tcp.addr] 110 | #TODO check if each flow is less than 16 MB (mongodb document limit) 111 | 112 | 113 | nids.param("pcap_filter", "tcp") # restrict to TCP only 114 | nids.chksum_ctl([('0.0.0.0/0', False)]) # disable checksumming 115 | 116 | if len(sys.argv) == 2: 117 | filename = sys.argv[1] 118 | if "./" in filename: 119 | filename = filename[2:] 120 | print("importing pcaps from " + filename) 121 | nids.param("filename", filename) 122 | else: 123 | print("pcap file required") 124 | exit() 125 | 126 | nids.init() 127 | nids.register_tcp(handleTcpStream) 128 | nids.run() 129 | 130 | print("importing " + str(len(flows_to_import)) + " flows into mongodb!") 131 | db.insertFlows(filename, flows_to_import) 132 | db.setFileImported(filename) 133 | -------------------------------------------------------------------------------- /src/components/FlowItem.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | 28 | //ui 29 | import { withStyles } from "@material-ui/core/styles"; 30 | import ListItem from "@material-ui/core/ListItem"; 31 | import Divider from "@material-ui/core/Divider"; 32 | import ListItemIcon from "@material-ui/core/ListItemIcon"; 33 | import Grid from "@material-ui/core/Grid"; 34 | import Checkbox from "@material-ui/core/Checkbox"; 35 | import Favorite from "@material-ui/icons/Favorite"; 36 | import FavoriteBorder from "@material-ui/icons/FavoriteBorder"; 37 | 38 | import moment from "moment"; 39 | 40 | import { setStarred } from "../data/fetcher.js"; 41 | const styles = theme => ({ 42 | root: { 43 | maxWidth: 360, 44 | paddingTop: 0 45 | } 46 | }); 47 | type FlowItem_type = { 48 | _id: *, 49 | inx: number, 50 | time: number, 51 | duration: number, 52 | src_ip: string, 53 | src_port: number, 54 | dst_ip: string, 55 | dst_port: number, 56 | contains_flag: boolean, 57 | starred: boolean, 58 | flow: Array<*> 59 | }; 60 | type props_types = { 61 | item: FlowItem_type, 62 | selected: boolean, 63 | hideFavourite: boolean, 64 | large: boolean, 65 | serviceName: string, 66 | classes: *, // material ui things 67 | onClick: FlowItem_type => void, 68 | onStar: (boolean) => void 69 | }; 70 | type state_types = { 71 | starred: boolean 72 | }; 73 | export class FlowItem extends Component { 74 | constructor(props: props_types) { 75 | super(props); 76 | this.state = { starred: props.item.starred || false }; 77 | } 78 | render() { 79 | const { item } = this.props; 80 | 81 | const item_color = this.getItemColor(item); 82 | return ( 83 |
84 | 92 | this.props.onClick && this.props.onClick(item) 93 | } 94 | > 95 | {this.renderItem(item)} 96 | 97 | 98 |
99 | ); 100 | } 101 | 102 | renderItem(item: FlowItem_type) { 103 | const checked = 104 | item.starred == null ? false : item.starred ? true : false; 105 | 106 | return ( 107 | 108 | {this.props.hideFavourite || ( 109 | 110 | } 112 | checkedIcon={} 113 | checked={checked} 114 | onClick={e => { 115 | setStarred(item._id["$oid"], !item.starred); 116 | this.props.onStar && 117 | this.props.onStar(!item.starred); 118 | e.stopPropagation(); 119 | }} 120 | /> 121 | 122 | )} 123 |
124 | {this.props.serviceName || item.dst_port} 125 | {this.props.large && this.getIpSourceDestInfo()} 126 | {this.getTimeInfo()} 127 |
128 |
129 | ); 130 | } 131 | 132 | getItemColor(item: FlowItem_type) { 133 | const isSelected = this.props.selected || false; 134 | if (isSelected) return "#03a9f4"; 135 | if (item.contains_flag) return "#FF6666"; 136 | return "#F5F5F5"; 137 | } 138 | getIpSourceDestInfo() { 139 | const item = this.props.item; 140 | return ( 141 |
142 | {item.src_ip + ":"} 143 | {item.src_port} {"⇨ " + item.dst_ip + ":"} 144 | 145 | {item.dst_port} 146 | 147 |
148 | ); 149 | } 150 | getTimeInfo() { 151 | const item = this.props.item; 152 | return ( 153 |
154 | {moment(item.time).format("HH:mm:ss,")} 155 | {moment(item.time).format("SSS")} 156 | {"ms "} 157 | {this.props.large && " duration: " + item.duration + "ms"} 158 |
159 | ); 160 | } 161 | } 162 | export default withStyles(styles)(FlowItem); 163 | -------------------------------------------------------------------------------- /src/registerServiceWorker.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // In production, we register a service worker to serve assets from local cache. 25 | 26 | // This lets the app load faster on subsequent visits in production, and gives 27 | // it offline capabilities. However, it also means that developers (and users) 28 | // will only see deployed updates on the "N+1" visit to a page, since previously 29 | // cached resources are updated in the background. 30 | 31 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. 32 | // This link also includes instructions on opting out of this behavior. 33 | 34 | const isLocalhost = Boolean( 35 | window.location.hostname === 'localhost' || 36 | // [::1] is the IPv6 localhost address. 37 | window.location.hostname === '[::1]' || 38 | // 127.0.0.1/8 is considered localhost for IPv4. 39 | window.location.hostname.match( 40 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 41 | ) 42 | ); 43 | 44 | export default function register() { 45 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 46 | // The URL constructor is available in all browsers that support SW. 47 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location); 48 | if (publicUrl.origin !== window.location.origin) { 49 | // Our service worker won't work if PUBLIC_URL is on a different origin 50 | // from what our page is served on. This might happen if a CDN is used to 51 | // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 52 | return; 53 | } 54 | 55 | window.addEventListener('load', () => { 56 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 57 | 58 | if (isLocalhost) { 59 | // This is running on localhost. Lets check if a service worker still exists or not. 60 | checkValidServiceWorker(swUrl); 61 | 62 | // Add some additional logging to localhost, pointing developers to the 63 | // service worker/PWA documentation. 64 | navigator.serviceWorker.ready.then(() => { 65 | console.log( 66 | 'This web app is being served cache-first by a service ' + 67 | 'worker. To learn more, visit https://goo.gl/SC7cgQ' 68 | ); 69 | }); 70 | } else { 71 | // Is not local host. Just register service worker 72 | registerValidSW(swUrl); 73 | } 74 | }); 75 | } 76 | } 77 | 78 | function registerValidSW(swUrl) { 79 | navigator.serviceWorker 80 | .register(swUrl) 81 | .then(registration => { 82 | registration.onupdatefound = () => { 83 | const installingWorker = registration.installing; 84 | installingWorker.onstatechange = () => { 85 | if (installingWorker.state === 'installed') { 86 | if (navigator.serviceWorker.controller) { 87 | // At this point, the old content will have been purged and 88 | // the fresh content will have been added to the cache. 89 | // It's the perfect time to display a "New content is 90 | // available; please refresh." message in your web app. 91 | console.log('New content is available; please refresh.'); 92 | } else { 93 | // At this point, everything has been precached. 94 | // It's the perfect time to display a 95 | // "Content is cached for offline use." message. 96 | console.log('Content is cached for offline use.'); 97 | } 98 | } 99 | }; 100 | }; 101 | }) 102 | .catch(error => { 103 | console.error('Error during service worker registration:', error); 104 | }); 105 | } 106 | 107 | function checkValidServiceWorker(swUrl) { 108 | // Check if the service worker can be found. If it can't reload the page. 109 | fetch(swUrl) 110 | .then(response => { 111 | // Ensure service worker exists, and that we really are getting a JS file. 112 | if ( 113 | response.status === 404 || 114 | response.headers.get('content-type').indexOf('javascript') === -1 115 | ) { 116 | // No service worker found. Probably a different app. Reload the page. 117 | navigator.serviceWorker.ready.then(registration => { 118 | registration.unregister().then(() => { 119 | window.location.reload(); 120 | }); 121 | }); 122 | } else { 123 | // Service worker found. Proceed as normal. 124 | registerValidSW(swUrl); 125 | } 126 | }) 127 | .catch(() => { 128 | console.log( 129 | 'No internet connection found. App is running in offline mode.' 130 | ); 131 | }); 132 | } 133 | 134 | export function unregister() { 135 | if ('serviceWorker' in navigator) { 136 | navigator.serviceWorker.ready.then(registration => { 137 | registration.unregister(); 138 | }); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | import "./App.css"; 28 | 29 | //components 30 | import FlowList from "./components/FlowList"; 31 | import FlowDetail from "./components/FlowDetail"; 32 | import MyToolbar from "./components/Toolbar"; 33 | 34 | //ui 35 | import { withStyles } from "@material-ui/core/styles"; 36 | import AppBar from "@material-ui/core/AppBar"; 37 | 38 | const styles = theme => ({ 39 | root: { 40 | flexGrow: 1, 41 | flexDirection: "rows", 42 | height: "100%", 43 | zIndex: 1, 44 | overflow: "hidden", 45 | position: "relative", 46 | display: "flex" 47 | }, 48 | appBar: { 49 | zIndex: theme.zIndex.drawer + 1, 50 | position: "fixed" 51 | }, 52 | toolbar: theme.mixins.toolbar 53 | }); 54 | type state_types = { 55 | flow_id: number, 56 | dst_ip: string, 57 | dst_port: number, 58 | text_filter: string, 59 | from_time: number, 60 | to_time: number, 61 | requestInProgress: boolean, 62 | hexdump: boolean, 63 | services: Array<*>, 64 | selected_flow : * 65 | }; 66 | type props_types = { 67 | classes: * 68 | }; 69 | var searchDelayTimer; 70 | class App extends Component { 71 | constructor(props) { 72 | super(props); 73 | 74 | this.state = { 75 | flow_id: 0, 76 | dst_ip: "", 77 | dst_port: 0, 78 | text_filter: "", 79 | from_time: 0, 80 | to_time: Number.MAX_SAFE_INTEGER, 81 | requestInProgress: false, 82 | hexdump: false, 83 | services: [], 84 | selected_flow: null 85 | }; 86 | } 87 | 88 | getFilters() { 89 | var res = {}; 90 | Object.assign(res, this.state); 91 | return res; //all'interno ci sono tutti i campi necessari 92 | } 93 | getFavouriteFilter() { 94 | var filters = this.getFilters(); 95 | filters["starred"] = 1; 96 | return filters; 97 | } 98 | 99 | search(text) { 100 | clearTimeout(searchDelayTimer); 101 | searchDelayTimer = setTimeout(() => { 102 | this.setState({ text_filter: text, requestInProgress: true }); 103 | }, 400); 104 | } 105 | 106 | render() { 107 | const { classes } = this.props; 108 | 109 | // todo handle flow list fetch failed 110 | const left_favourites_bar = ( 111 | { 115 | console.log("Selezionato un flow"); 116 | this.setState({ selected_flow: flow }); 117 | }} 118 | onFlowsLoaded={() => this.setState({ requestInProgress: false })} 119 | services={this.state.services} 120 | width={300} 121 | largeItems={false} 122 | /> 123 | ); 124 | 125 | const flow_list = ( 126 | { 130 | console.log("Selezionato un flow"); 131 | this.setState({ selected_flow: flow }); 132 | }} 133 | largeItems={true} 134 | onFlowsLoaded={() => this.setState({ requestInProgress: false })} 135 | services={this.state.services} 136 | width={450} 137 | /> 138 | ); 139 | const myToolbar = ( 140 | { 142 | this.search(text); 143 | }} 144 | onTimeSet={(from, to) => { 145 | console.log("selected from: " + from + " to " + to); 146 | this.setState({ from_time: from, to_time: to }); 147 | }} 148 | onTargetChanged={(dst_ip, dst_port) => { 149 | console.log("new target: "); 150 | console.log(dst_ip + " " + dst_port); 151 | this.setState({ 152 | dst_ip: dst_ip, 153 | dst_port: dst_port, 154 | requestInProgress: true 155 | }); 156 | }} 157 | hexdump={this.state.hexdump} 158 | toggleHexdump={() => 159 | this.setState({ hexdump: !this.state.hexdump }) 160 | } 161 | onServicesFetched={services => { 162 | console.log("services fetched:"); 163 | console.log(services); 164 | this.setState({ services: services }); 165 | }} 166 | requestInProgress={this.state.requestInProgress} 167 | /> 168 | ); 169 | const flow_details = this.state.selected_flow && ( 170 | 176 | ); 177 | return ( 178 |
179 | 180 | {myToolbar} 181 | 182 |
183 |
184 |
{left_favourites_bar}
185 |
{flow_list}
186 |
{flow_details}
187 |
188 |
189 | ); 190 | } 191 | } 192 | export default withStyles(styles)(App); 193 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![circleci][circleci-shield]][circleci-shield] 3 | [![Contributors][contributors-shield]][contributors-url] 4 | [![Forks][forks-shield]][forks-url] 5 | [![Pull requests][pr-shield]][pr-url] 6 | [![Stargazers][stars-shield]][stars-url] 7 | [![Issues][issues-shield]][issues-url] 8 | [![GPL License][license-shield]][license-url] 9 | 10 | 11 |
12 |

13 | 14 | 15 | 16 | 17 |

Flower

18 |

19 | TCP flow analyzer with sugar for Attack/Defence CTF 20 |
21 | Report Bug 22 | · 23 | Request Feature 24 | · 25 | View Features 26 |

27 |

28 | 29 | ## Table of Contents 30 | 31 | - [Table of Contents](#table-of-contents) 32 | - [What is it?](#what-is-it) 33 | - [Features](#features) 34 | - [Getting Started](#getting-started) 35 | - [Run with docker](#run-with-docker) 36 | - [Manual installation](#manual-installation) 37 | - [Run](#run) 38 | - [Pcap import](#pcap-import) 39 | - [Security tips (Important!)](#security-tips-important) 40 | - [Credits](#credits) 41 | 42 | ## What is it? 43 | 44 | ![demo_image](https://github.com/secgroup/flower/blob/master/demo_images/demo3.png?raw=true) 45 | 46 | Flower is an automatic packet analyzer made by Ca' Foscari University team for CyberChallenge attack/defense CTF held in Rome on the June 27th, 2018. 47 | 48 | This tool was written in less than ten days, but it works! Every **contribution** is welcome! 49 | 50 | Presentation of Flower (from min 7:30), and general introduction to CTFs at ESC2K18 in italian: 51 | 52 | [![tools presentation](http://img.youtube.com/vi/oGB7LFwTghE/0.jpg)](http://www.youtube.com/watch?v=oGB7LFwTghE) 53 | 54 | ## Features 55 | - Only one command needed to have it up, thanks to docker. 56 | - Flow list 57 | - **Vim like navigation** ( `k` and `j` to navigate the list) 58 | - Regex filtering with highlight 59 | ![](https://github.com/secgroup/flower/blob/master/demo_images/demo_search_hilight.png?raw=true) 60 | - Highlight in red flow with flags 61 | - Favourite management 62 | - Time filter 63 | - Service filter 64 | ![](https://github.com/secgroup/flower/blob/master/demo_images/demo_service_selection.png) 65 | - Colored hexdump 66 | ![](https://github.com/secgroup/flower/blob/master/demo_images/demo_hex_dump.png?raw=true) 67 | - Automatic export GET/POST requests directly in python format 68 | ![](https://github.com/secgroup/flower/blob/master/demo_images/demo_request_export.png) 69 | - Automatic export to pwntools 70 | ![](https://github.com/secgroup/flower/blob/master/demo_images/demp_export_pwn.png) 71 | 72 | ## Getting Started 73 | 74 | ### Run with docker 75 | 76 | Clone the repo, enter in the directory, and just run `docker-compose up`, and after a while you will find flower at [http://localhost:3000](http://localhost:3000). 77 | 78 | For the flag regex, modify `REACT_APP_FLAG_REGEX` in `docker-compose.yml`. 79 | 80 | The build will automatically import the test pcaps. 81 | 82 | To enter in the service to import other pcaps, run `docker exec -it flower_flower-python_1 /bin/bash` (if flower is in a folder with a different name, modify the prefix after `-it`). 83 | The container share the `/shared` folder with the host. Put the pcap files inside this folder and use `python services/importer.py /shared/pcap_file_here` from the container to import pcaps to flower. 84 | 85 | ### Manual installation 86 | 87 | 1. Clone and install dependencies 88 | ```bash 89 | git clone https://github.com/secgroup/flower 90 | cd flower 91 | npm install 92 | pip install -r services/requirements.txt 93 | ``` 94 | 2. (Optional) Set the following environment variables: 95 | - `REACT_APP_FLOWER_MONGO` ip of the host that will have flower db active (mongodb) 96 | - `REACT_APP_FLOWER_SERVICES` ip of the host that will have services active 97 | - `REACT_APP_FLAG_REGEX` regex that match flags. 98 | 99 | 3. Mongodb is required on the same machine that run the services. 100 | To start it: `sudo mongod --dbpath /path/to/mongodb/db --bind_ip 0.0.0.0` 101 | 102 | 103 | #### Run 104 | 1. Start flower 105 | ```bash 106 | ./run.sh 107 | ``` 108 | 2. Start flower services 109 | ```bash 110 | cd services 111 | ./run_ws.sh 112 | ``` 113 | Once everything has been started, flower should be accessible at the address of the machine that started it on port 3000. 114 | 115 | 116 | ### Pcap import 117 | You must first install pynids from [here](https://github.com/MITRECND/pynids). The pip version is outdated! Good luck with the installation. 118 | Then, you can import pcaps into mongodb by executing the provided script `importer.py` as follows: 119 | ``` 120 | cd services 121 | ./importer.py pcap_file.pcap 122 | ``` 123 | You can find a test_pcap in `services/test_pcap`. For a quick demo, run `./importer.py test_pcap/dump-2018-06-27_13:25:31.pcap` 124 | 125 | ## Security tips (Important!) 126 | 127 | If you are going to use flower in a CTF, remember to set up the firewall in the most appropriate way, as the current implementation does not use other security techniques. 128 | > If you ignore this, everybody will be able to connect to your database and steal all your flags! 129 | 130 | 131 | ## Credits 132 | - [Nicolò Mazzucato](https://github.com/nicomazz) 133 | - Antonio Groza 134 | - Simone Brunello 135 | - Alessio Marotta 136 | 137 | With the support of [c00kies@venice](https://secgroup.github.io/) 138 | 139 | 140 | 141 | 142 | [circleci-shield]: https://circleci.com/gh/secgroup/flower.svg?style=shield 143 | 144 | [contributors-shield]: https://img.shields.io/github/contributors/secgroup/flower.svg?style=flat-square 145 | [contributors-url]: https://github.com/secgroup/flower/graphs/contributors 146 | 147 | [forks-shield]: https://img.shields.io/github/forks/secgroup/flower.svg?style=flat-square 148 | [forks-url]: https://github.com/secgroup/flower/network/members 149 | 150 | [stars-shield]: https://img.shields.io/github/stars/secgroup/flower.svg?style=flat-square 151 | [stars-url]: https://github.com/secgroup/flower/stargazers 152 | 153 | [issues-shield]: https://img.shields.io/github/issues/secgroup/flower.svg?style=flat-square 154 | [issues-url]: https://github.com/secgroup/flower/issues 155 | 156 | [license-shield]: https://img.shields.io/github/license/secgroup/flower.svg?style=flat-square 157 | [license-url]: https://github.com/secgroup/flower/blob/master/LICENSE.txt 158 | 159 | [pr-shield]: https://img.shields.io/github/issues-pr/secgroup/flower.svg?style=flat-square 160 | [pr-url]: https://github.com/secgroup/flower/pulls 161 | 162 | [product-screenshot]: images/screenshot.png 163 | -------------------------------------------------------------------------------- /src/components/FlowList.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | 28 | import { withStyles } from "@material-ui/core/styles"; 29 | import { List, AutoSizer } from "react-virtualized"; 30 | 31 | import FlowItem from "./FlowItem"; 32 | import FlowItem_type from "./FlowItem"; 33 | import { fetchFlows } from "../data/fetcher"; 34 | //import VirtualList from "react-tiny-virtual-list"; 35 | 36 | import _ from "lodash/core"; 37 | 38 | const styles = theme => ({ 39 | root: { 40 | overflow: "auto", 41 | maxWidth: 360, 42 | backgroundColor: theme.palette.background.paper 43 | } 44 | }); 45 | 46 | type state_types = { 47 | data: Array, 48 | filters_applied: *, 49 | selected_inx: number 50 | }; 51 | type props_types = { 52 | largeItems: boolean, 53 | filters: *, 54 | onFlowsLoaded: () => void, 55 | onFlowSelected: FlowItem_type => void, 56 | list_id: string, 57 | classes: *, //material ui things 58 | services: Array<*> 59 | }; 60 | export class FlowList extends Component { 61 | constructor(props: props_types) { 62 | super(props); 63 | this.state = { data: [], filters_applied: {}, selected_inx: 0 }; 64 | } 65 | componentDidMount() { 66 | this.loadFlows(); 67 | } 68 | componentDidUpdate() { 69 | this.loadFlows(); 70 | } 71 | 72 | loadFlows() { 73 | var filters = this.props.filters; 74 | //teniamo solo le chiavi che ci interessano 75 | //todo non usare testo hardcoded 76 | var prop = [ 77 | "text_filter", 78 | "dst_ip", 79 | "dst_port", 80 | "from_time", 81 | "to_time", 82 | "starred" 83 | ]; 84 | for (var k in filters) { 85 | if (prop.indexOf(k) < 0) { 86 | delete filters[k]; 87 | } 88 | } 89 | 90 | if (_.isEqual(filters, this.state.filters_applied)) return; 91 | this.setState({ 92 | filters_applied: filters 93 | }); 94 | fetchFlows(filters, flows => { 95 | console.log("ok, ho i flows!: "); 96 | console.log(flows); 97 | this.setState({ 98 | data: flows, 99 | filters_applied: filters 100 | }); 101 | this.props.onFlowsLoaded(); 102 | }); 103 | } 104 | 105 | renderRow = ({ index, key, style }) => { 106 | let item = this.state.data[index]; 107 | return ( 108 |
109 | { 115 | this.setState({ selected_inx: index }); 116 | this.props.onFlowSelected(flow); 117 | }} 118 | onStar={star => { 119 | console.log("Cambio stato stella!"); 120 | let data = [...this.state.data]; 121 | data[index].starred = star; //new value 122 | this.setState({ data }); 123 | }} 124 | large={this.props.largeItems} 125 | /> 126 |
127 | ); 128 | }; 129 | 130 | handleKeyPress = (e: KeyboardEvent) => { 131 | console.log("premuto:" + e.key); 132 | if (e.key === "k") { 133 | console.log("up key detected."); 134 | if (this.state.selected_inx === 0) return; 135 | this.setState(prevState => ({ 136 | selected_inx: prevState.selected_inx - 1 137 | })); 138 | this.props.onFlowSelected( 139 | this.state.data[this.state.selected_inx - 1] 140 | ); 141 | this.list.scrollToRow(this.state.selected_inx); 142 | } else if (e.key === "j") { 143 | console.log("down key detected."); 144 | if (this.state.selected_inx === this.state.data.length - 1) return; 145 | this.setState(prevState => ({ 146 | selected_inx: prevState.selected_inx + 1 147 | })); 148 | this.props.onFlowSelected( 149 | this.state.data[this.state.selected_inx + 1] 150 | ); 151 | this.list.scrollToRow(this.state.selected_inx + 2); 152 | } 153 | }; 154 | 155 | render() { 156 | 157 | var data = this.state.data; 158 | console.log("richiamato render flow list"); 159 | 160 | return ( 161 | 162 | {({ height, width }) => ( 163 |
164 | { 171 | this.list = list; 172 | }} 173 | rowRenderer={this.renderRow} 174 | rowCount={data.length} 175 | /> 176 |
177 | )} 178 |
179 | ); 180 | } 181 | 182 | getServiceName(item: FlowItem_type) { 183 | var port = item.dst_port; 184 | for (var service of this.props.services) { 185 | if (service.port === port) return service.name; 186 | } 187 | return "unknown"; 188 | } 189 | } 190 | 191 | export default withStyles(styles)(FlowList); 192 | -------------------------------------------------------------------------------- /src/components/Toolbar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | import Toolbar from "@material-ui/core/Toolbar"; 28 | import SearchBar from "material-ui-search-bar"; 29 | import Typography from "@material-ui/core/Typography"; 30 | import CircularProgress from "@material-ui/core/CircularProgress"; 31 | import Checkbox from "@material-ui/core/Checkbox"; 32 | import FormControlLabel from "@material-ui/core/FormControlLabel"; 33 | import TextField from "@material-ui/core/TextField"; 34 | 35 | import { withStyles } from "@material-ui/core/styles"; 36 | import IconButton from "@material-ui/core/IconButton"; 37 | 38 | import ServiceSelector from "./ServiceSelector"; 39 | import Service_type from "./ServiceSelector"; 40 | const styles = theme => ({ 41 | appBar: { 42 | zIndex: theme.zIndex.drawer + 1, 43 | position: "fixed" 44 | }, 45 | toolbar: theme.mixins.toolbar, 46 | progress: { 47 | margin: theme.spacing.unit 48 | }, 49 | textField: { 50 | marginLeft: theme.spacing.unit, 51 | marginRight: theme.spacing.unit, 52 | width: 100, 53 | borderRadius: 2, 54 | padding: 3, 55 | backgroundColor: "#FFFFFF" 56 | }, 57 | serviceSelector: { 58 | marginLeft: theme.spacing.unit, 59 | marginRight: theme.spacing.unit, 60 | borderRadius: 2, 61 | backgroundColor: "#FFFFFF" 62 | } 63 | }); 64 | type props_types = { 65 | classes: *, 66 | onTargetChanged: (*) => void, 67 | hexdump: boolean, 68 | requestInProgress: boolean, 69 | onRequestSearch: string => void, 70 | toggleHexdump: boolean => void, 71 | onTimeSet: (number, number) => void, 72 | onServicesFetched: (Array) => void 73 | }; 74 | type state_types = { 75 | from_time: number, 76 | to_time: number 77 | }; 78 | export class MyToolbar extends Component { 79 | constructor(props: props_types) { 80 | super(props); 81 | this.state = { 82 | from_time: 0, 83 | to_time: Number.MAX_SAFE_INTEGER 84 | }; 85 | } 86 | render() { 87 | const { classes } = this.props; 88 | 89 | return ( 90 | 91 | 92 | 93 | {/*// eslint-disable-next-line*/} 94 | 95 | Flower 96 | 97 | 🌸 98 | 107 | { 120 | var time = this.getTimeFromString(item.target.value); 121 | console.log(item.target.value); 122 | this.setState({ from_time: time }); 123 | this.props.onTimeSet(time, this.state.to_time); 124 | }} 125 | /> 126 | { 139 | var time = this.getTimeFromString(item.target.value); 140 | if (item === 0) item = Number.MAX_SAFE_INTEGER; 141 | console.log(item.target.value); 142 | this.setState({ to_time: time }); 143 | this.props.onTimeSet(this.state.from_time, time); 144 | }} 145 | /> 146 |
147 | 152 |
153 | 154 | 161 | } 162 | className={classes.checkbox} 163 | label="Hexdump" 164 | style={{ margin: 5 }} 165 | /> 166 | 167 | {this.props.requestInProgress ? ( 168 | 172 | ) : null} 173 |
174 | ); 175 | } 176 | 177 | getActualTimeString() { 178 | var d = new Date(); 179 | return d.getHours() + ":" + d.getMinutes(); 180 | } 181 | getTimeFromString(time_str: string) { 182 | if (time_str.length === 0) return 0; 183 | var h = parseInt(time_str.split(":")[0],10); 184 | var min = parseInt(time_str.split(":")[1],10); 185 | var d = new Date(); 186 | d.setUTCHours(h - 2); //fast time-zone fix TODO FIX THIS 187 | d.setUTCMinutes(min); 188 | return d.getTime(); 189 | } 190 | } 191 | export default withStyles(styles)(MyToolbar); 192 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | image/svg+xml -------------------------------------------------------------------------------- /src/components/FlowDetail.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Flower. 3 | * 4 | * Copyright ©2018 Nicolò Mazzucato 5 | * Copyright ©2018 Antonio Groza 6 | * Copyright ©2018 Brunello Simone 7 | * Copyright ©2018 Alessio Marotta 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 | * 10 | * Flower is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * Flower is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with Flower. If not, see . 22 | */ 23 | 24 | // @flow 25 | 26 | import React, { Component } from "react"; 27 | import { fetchFlow, getPythonRequest, getPwnRequest } from "../data/fetcher"; 28 | import SimpleModalWrapped from "./CopyModal"; 29 | import FlowItem_type from "./FlowItem"; 30 | 31 | //ui 32 | import FlowItem from "./FlowItem"; 33 | import Paper from "@material-ui/core/Paper"; 34 | import { withStyles } from "@material-ui/core/styles"; 35 | 36 | //utility 37 | import DOMPurify from "dompurify"; 38 | import hexdump from "hexdump-nodejs"; 39 | 40 | const styles = theme => ({ 41 | root: theme.mixins.gutters({ 42 | paddingTop: 16, 43 | paddingBottom: 16, 44 | marginTop: theme.spacing.unit * 3 45 | }), 46 | paper: { 47 | position: "fixed", 48 | backroundColor: "#000000", 49 | bottom: 0, 50 | top: 70, 51 | right: 0, 52 | overflow: "auto", 53 | margin: 20, 54 | width: "50%" 55 | } 56 | }); 57 | 58 | type state_types = { 59 | flow_id: string, 60 | flow_data: Array, 61 | to_copy: string, 62 | modal_opened: boolean 63 | }; 64 | type props_types = { 65 | classes: *, 66 | flow: FlowItem_type, 67 | hexdump: boolean, 68 | filter: * 69 | }; 70 | export class FlowDetail extends Component { 71 | constructor(props: props_types) { 72 | super(props); 73 | this.state = { 74 | flow_id: "", 75 | flow_data: [], 76 | to_copy: "", 77 | modal_opened: false 78 | }; 79 | } 80 | 81 | componentDidMount() { 82 | this.loadFlow(); 83 | } 84 | componentDidUpdate() { 85 | this.loadFlow(); 86 | } 87 | loadFlow() { 88 | const flow_id = this.props.flow._id["$oid"]; 89 | 90 | if (this.state.flow_id === flow_id) { 91 | console.log("non Aggiorno, è quello di prima!"); 92 | return; 93 | } 94 | fetchFlow(flow_id, flow => { 95 | this.setState({ flow_id: flow_id, flow_data: flow.flow }); 96 | }); 97 | } 98 | onClose() { 99 | this.setState({ modal_opened: false }); 100 | } 101 | render() { 102 | const { classes } = this.props; 103 | 104 | const this_flow = this.props.flow; 105 | console.log(this_flow); 106 | const this_flow_data = this.state.flow_data; 107 | return ( 108 | 109 | {/* modal for copy*/} 110 | this.onClose()} 113 | isOpen={this.state.modal_opened} 114 | /> 115 | 116 |
118 | this.fetchPwnTextToCopy(this_flow["_id"]["$oid"]) 119 | } 120 | > 121 | Copy Pwn 122 |
123 | 124 |
125 | {this_flow_data.map((item, inx) => 126 | this.renderItem(item, inx) 127 | )} 128 |
129 |
130 | ); 131 | } 132 | 133 | renderItem(item: FlowItem_type, inx: number) { 134 | const start_time = this.props.flow.time; 135 | 136 | return ( 137 |
{ 139 | this.fetchTextToCopy(item); 140 | }} 141 | > 142 | 150 |
155 | {" "} 156 | {"" + inx + ". "} 157 | {item.from === "c" ? "Server" : "Client"}{" "} 158 | {" +" + (item.time - start_time) + " ms"} 159 |
171 |                     
172 |
173 |
174 | ); 175 | } 176 | fetchTextToCopy(item: FlowItem_type) { 177 | getPythonRequest(item.data, to_copy => { 178 | this.openModalWithText(to_copy); 179 | }); 180 | } 181 | fetchPwnTextToCopy(item: FlowItem_type) { 182 | console.log("item id:"); 183 | console.log(item); 184 | getPwnRequest(item, to_copy => { 185 | this.openModalWithText(to_copy); 186 | }); 187 | } 188 | openModalWithText(text: string) { 189 | console.log("to_copy: "); 190 | console.log(text); 191 | this.setState({ modal_opened: true, to_copy:text }); 192 | } 193 | 194 | get_text_formatted(item: FlowItem_type) { 195 | return this.props.hexdump 196 | ? this.get_hexdump(item.hex) 197 | : this.hilight_flag(item.data); 198 | } 199 | //convert hex string to ascii string 200 | fromHex(h: string) { 201 | var s = ""; 202 | for (var i = 0; i < h.length; i += 2) { 203 | s += String.fromCharCode(parseInt(h.substr(i, 2), 16)); 204 | } 205 | return s; 206 | } 207 | get_hexdump(text: string) { 208 | var toDump = this.fromHex(text); 209 | var buffer = new Buffer(toDump.length); 210 | buffer.write(toDump); 211 | return this.color_hexdump( 212 | hexdump(buffer).replace("Offset ", "Offset _") //fix this 213 | ); 214 | } 215 | color_hexdump(text: string) { 216 | var lines = text.split("\n"); 217 | var result = ""; 218 | for (var line of lines) result += this.color_hexdump_line(line); 219 | return result; 220 | } 221 | color_hexdump_line(line: string) { 222 | if (line.length === 0) return ""; 223 | var colors = ["#993300", "#000099", "#993300", "#000099"]; //inizialmente sopportava 4 colori 224 | var offset = line.substring(0, 10); 225 | var bytes = line.substring(10, 10 + 48); 226 | var bytes_result = ""; 227 | 228 | for (var i = 0; i < 48; i += 12) 229 | bytes_result += 230 | '' + 233 | bytes.substring(i, i + 12) + 234 | ""; 235 | 236 | var rem = line.substring(10 + 49); 237 | var text_result = ""; 238 | for (i = 0; i < rem.length; i += rem.length / 4) 239 | text_result += 240 | '' + 243 | rem.substring(i, i + rem.length / 4) + 244 | ""; 245 | 246 | return offset + bytes_result + "|" + text_result + "|\n"; 247 | } 248 | 249 | getFlagRegex() : string { 250 | return process.env.REACT_APP_FLAG_REGEX || "[A-Z0-9]{31}="; 251 | } 252 | hilight_flag(text: string) { 253 | //text = escape(text) 254 | // if (!this.props.regex) return text; 255 | var reg_string :string = this.props.filter 256 | ? this.props.filter 257 | : this.getFlagRegex() 258 | console.log("hilight string:"); 259 | console.log(reg_string); 260 | 261 | var reg = new RegExp(reg_string, "i"); //this.props.regex); 262 | 263 | var final_str = 264 | "" + 265 | text.replace(reg, function(str) { 266 | return '' + str + ""; 267 | }); 268 | 269 | // speriamo basti.. 270 | return DOMPurify.sanitize(final_str); 271 | } 272 | } 273 | 274 | export default withStyles(styles)(FlowDetail); 275 | -------------------------------------------------------------------------------- /demo_images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 30 | 34 | 35 | 45 | 48 | 52 | 56 | 57 | 67 | 77 | 87 | 90 | 94 | 98 | 99 | 109 | 110 | 133 | 135 | 136 | 138 | image/svg+xml 139 | 141 | 142 | 143 | 144 | 145 | 150 | 154 | 160 | 165 | 171 | 177 | 182 | 187 | 192 | 197 | 202 | 207 | 212 | 218 | 223 | 229 | 235 | 241 | 247 | 253 | 258 | 264 | 270 | 275 | 280 | 285 | 290 | 295 | 300 | 305 | 306 | 307 | 308 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------