This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add portscan integration * Remove internal deps from unit testing * Fix ioloop issues * Update default configuration * Update py_clib and add logging configuration
- Loading branch information
Dominik
authored
Jan 8, 2018
1 parent
f3d8194
commit f740111
Showing
15 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
PYLINT_FILES=$(find . -name "*.py" -not -path "./tests/*" -not -path "./venv/*") | ||
PYLINT_FILES=$(find . -name "*.py" -not -path "./tests/*" -not -path "./venv/*" -not -path "./internal_deps*") | ||
|
||
bandit -ll ${PYLINT_FILES} | tee bandit.txt | ||
exit ${PIPESTATUS[0]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
FILES=$(find . -maxdepth 1 -type d) | ||
nosetests --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=. ${FILES} || exit 1 | ||
FILES=$(find . -maxdepth 1 -type d -not -path "./internal_deps*") | ||
nosetests --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=. ${FILES} || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
url = [email protected]:FCG-LLC/ci-utils.git | ||
[submodule "internal_deps/py_cslib"] | ||
path = internal_deps/py_cslib | ||
url = [email protected]:FCG-LLC/py_cslib | ||
url = [email protected]:FCG-LLC/py_cslib.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule py_cslib
updated
from 65294d to cf1644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
from asyncio import get_event_loop | ||
|
||
from scans.scanner import Scanner | ||
from structs import TransportProtocol | ||
from tools.masscan import MasscanPorts | ||
from tools.nmap.ports import PortsScan | ||
from utils.portscan import PortscanScanner | ||
|
||
|
||
class TCPScanner(Scanner): | ||
PROTOCOL = TransportProtocol.TCP | ||
NAME = 'tcp' | ||
|
||
def __init__(self, host, port, *args, **kwargs): | ||
super(TCPScanner, self).__init__(*args, **kwargs) | ||
self.host = host | ||
self.port = port | ||
self._tcp_scanner = PortscanScanner(self.host, self.port, get_event_loop()) | ||
|
||
@property | ||
def scanners(self): | ||
return { | ||
self.IPV4: [MasscanPorts(udp=False)], | ||
self.IPV6: [PortsScan(ipv6=True, tcp=True, udp=False)] | ||
self.IPV4: [self._tcp_scanner], | ||
self.IPV6: [self._tcp_scanner] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from asyncio import ensure_future | ||
from collections import namedtuple | ||
|
||
from pycslib.scan_engines import Portscan | ||
from pycslib.utils.nmap import ports_to_string | ||
|
||
from aucote_cfg import cfg | ||
from structs import TransportProtocol, Port, Scan | ||
from tools.nmap.tool import NmapTool | ||
|
||
|
||
class PortscanScanner(object): | ||
def __init__(self, host, port, io_loop): | ||
self.portscan = Portscan(host, port, io_loop) | ||
self.command = namedtuple('command', 'NAME')('portscan') | ||
ensure_future(self.portscan.connect(), loop=io_loop) | ||
|
||
async def scan_ports(self, nodes): | ||
include_ports = NmapTool.ports_from_list(tcp=cfg['portdetection.tcp.ports.include']).get(TransportProtocol.TCP) | ||
exclude_ports = NmapTool.ports_from_list(tcp=cfg['portdetection.tcp.ports.exclude']).get(TransportProtocol.TCP) | ||
|
||
ports = list(include_ports - exclude_ports) | ||
|
||
task = {str(node.ip): ports_to_string(set(ports)) for node in nodes} | ||
|
||
found_ports = await self.portscan.send(task) | ||
|
||
return list({ | ||
Port(number=port, node=node, transport_protocol=TransportProtocol.TCP, scan=Scan(start=node.scan.start)) | ||
for node in nodes | ||
for port in found_ports.get(str(node.ip)) | ||
}) |