@@ -2,45 +2,54 @@ use std::process::Command;
22use tracing;
33
44use crate :: { config:: db:: Pool , constants, models:: {
5- user :: { LoginDTO } ,
5+ scan :: { IP , Domain } ,
66 response:: ResponseBody ,
77} } ;
88use actix_web:: { web, HttpRequest , HttpResponse , Result } ;
99
10- pub async fn scan_online ( req : HttpRequest ) -> Result < HttpResponse > {
10+ pub async fn scan_online ( ip : web :: Json < IP > ) -> Result < HttpResponse > {
1111
12- debug ! ( "req: {:?}" , req) ;
12+ // println!("ip: {:?}", ip.ip);
13+ let ip: & str = ip. ip . as_ref ( ) ;
1314
1415 let output =
15- Command :: new ( "ls" )
16- . arg ( "-l" )
17- . arg ( "-a" )
16+ Command :: new ( "/usr/local/bin/rustscan" )
17+ . arg ( format ! ( "-a {}" , ip) )
18+ . arg ( "--accessible" )
19+ . arg ( "--ulimit 5000" )
20+ . arg ( "--ports 443,80,8080,8000,5000,3000" )
1821 . output ( )
19- . expect ( "ls command failed to start" ) ;
22+ . expect ( "command failed to start" ) ;
23+
2024 debug ! ( "status: {:?}" , output. status) ;
2125 debug ! ( "stdout: {:?}" , String :: from_utf8_lossy( & output. stdout) ) ;
2226 debug ! ( "stderr: {:?}" , String :: from_utf8_lossy( & output. stderr) ) ;
2327
2428 let response = String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ;
29+ println ! ( "stderr response: {:?}" , & output. stderr) ;
30+ println ! ( "stdout response: {:?}" , response) ;
2531 Ok ( HttpResponse :: Ok ( ) . json ( ResponseBody :: new ( constants:: EMPTY , response) ) )
2632
2733}
2834
29- pub async fn scan_ssl ( req : HttpRequest ) -> Result < HttpResponse > {
35+ pub async fn scan_ssl ( domain : web :: Json < Domain > ) -> Result < HttpResponse > {
3036
31- debug ! ( "req: {:?}" , req) ;
37+ // debug!("req: {:?}", req);
3238
3339 let output =
34- Command :: new ( "ls" )
35- . arg ( "-l" )
36- . arg ( "-a" )
40+ Command :: new ( "/usr/bin/openssl" )
41+ . arg ( "s_client" )
42+ . arg ( "-connect" )
43+ . arg ( format ! ( "{}:443" , domain. name) )
3744 . output ( )
38- . expect ( "ls command failed to start" ) ;
45+ . expect ( "command failed to start" ) ;
3946
4047 debug ! ( "status: {:?}" , output. status) ;
4148 debug ! ( "stdout: {:?}" , String :: from_utf8_lossy( & output. stdout) ) ;
4249 debug ! ( "stderr: {:?}" , String :: from_utf8_lossy( & output. stderr) ) ;
4350
4451 let response = String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ;
52+ println ! ( "stderr response: {:?}" , & output. stderr) ;
53+ println ! ( "stdout response: {:?}" , response) ;
4554 Ok ( HttpResponse :: Ok ( ) . json ( ResponseBody :: new ( constants:: EMPTY , response) ) )
4655}
0 commit comments