2 个版本
0.1.1 | 2022年1月13日 |
---|---|
0.1.0 | 2022年1月13日 |
#6 in #收集
24KB
402 代码行
火舌
端口扫描 API
这是一个用于“Pelican”,一个免费开源的数据收集平台的 API。目前仍处于原型阶段。
以下是可用功能
use fuego::carriers::{CommonCarrier, RadioFlyer};
use fuego::constants::COMMON_PORTS;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//Get a banner
let record = RadioFlyer::get_banner("example.com", 80);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
let record = RadioFlyer::string_drop(
"example.com",
"GET / HTTP/1.1\n\n",
80
);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
//Get the hosts
let hosts = RadioFlyer::host_drop("example.com");
assert_eq!(hosts.is_ok(), true);
let unwrapped = hosts.unwrap();
assert_eq!(unwrapped.len() > 0, true);
println!("{:?}", hosts);
//Port scan a host
let ports: Vec<u16> = COMMON_PORTS.to_vec();
let record = RadioFlyer::scan_drop("8.8.8.8", ports, 100);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
//Banner scan a host
let ports: Vec<u16> = COMMON_PORTS.to_vec();
let record = RadioFlyer::banner_drop("example.com", ports, 100);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
//Scan multiple hosts with common ports
let ports: Vec<u16> = COMMON_PORTS.to_vec();
let record = RadioFlyer::scan_drops(
vec![
"2001:4860:4860:0000:0000:0000:0000:8888",
"8.8.8.8",
"8.8.4.4",
"example.com",
],
ports,
50,
);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
//Banner scan multiple hosts
let ports: Vec<u16> = COMMON_PORTS.to_vec();
let record = RadioFlyer::banner_drops(
vec![
"2001:4860:4860:0000:0000:0000:0000:8888",
"8.8.8.8",
"8.8.4.4",
"example.com",
],
ports,
50,
);
assert_eq!(record.is_ok(), true);
println!("{:?}", record.unwrap());
//from a json file
let record = CommonCarrier::from_file("./assets/import_test.json");
assert_eq!(record.is_ok(), true);
let unwrapped = record.unwrap();
println!("{:?}", record.unwrap());
}
##JSON 格式示例
{
"addresses": [{
"host": "google.com",
"ports": [53, 123, 8006]
},
{
"host": "example.com",
"ports": [53, 123]
},
{
"host": "8.8.8.8",
"ports": [53, 123]
},
{
"host": "8.8.4.4",
"ports": [53, 123]
},
{
"host": "2001:4860:4860:0000:0000:0000:0000:8888",
"ports": [53, 123]
}
],
"global_ports": [80,443]
}
依赖
~4–11MB
~105K SLoC