11# !/usr/bin/env perl
22#
3- # $Id: onyphe,v 45178b147667 2024/03/27 14:29:16 gomor $
3+ # $Id: onyphe,v b6fb1a68219a 2024/08/15 11:22:51 gomor $
44#
55use strict;
66use warnings;
77
8- our $VERSION = ' 4.00' ;
9-
108use Getopt::Long;
119use Onyphe::Api;
1210use OPP;
@@ -48,6 +46,8 @@ GetOptions(
4846 " riskscan=i" => \$lopts {' riskscan' }, # -riskscan 1
4947 " asm=i" => \$lopts {' asm' }, # -asm 1
5048 " import=i" => \$lopts {' import' }, # -import 1
49+ " count" => \$lopts {' count' }, # -count
50+ " trusted=i" => \$lopts {' trusted' }, # -trusted 0
5151 # APIs:
5252 " user" => \$lopts {user }, # -user
5353 " summary=s" => \$lopts {summary }, # -summary ip|domain|hostname
@@ -60,6 +60,7 @@ GetOptions(
6060 " search" => \$lopts {search }, # -search
6161 " postsearch" => \$lopts {postsearch }, # -postsearch
6262 " export" => \$lopts {export }, # -export
63+ " postexport" => \$lopts {postexport }, # -postexport
6364 " alert-list" => \$lopts {' alert-list' }, # -alert-list
6465 " alert-add" => \$lopts {' alert-add' }, # -alert-add
6566 " alert-del=s" => \$lopts {' alert-del' }, # -alert-del 0
@@ -72,9 +73,13 @@ GetOptions(
7273 " ondemand-scope-domain-bulk=s" => \$lopts {' ondemand-scope-domain-bulk' }, # -ondemand-scope-domain-bulk INPUT.txt
7374 " ondemand-scope-hostname=s" => \$lopts {' ondemand-scope-hostname' }, # -ondemand-scope-hostname HOSTNAME
7475 " ondemand-scope-hostname-bulk=s" => \$lopts {' ondemand-scope-hostname-bulk' }, # -ondemand-scope-hostname-bulk INPUT.txt
76+ " ondemand-scope-port=s" => \$lopts {' ondemand-scope-port' }, # -ondemand-scope-port PORT
7577 " ondemand-scope-result=s" => \$lopts {' ondemand-scope-result' }, # -ondemand-scope-result ID
7678 " ondemand-resolver-domain=s" => \$lopts {' ondemand-resolver-domain' }, # -ondemand-resolver-domain DOMAIN
7779 " ondemand-resolver-result=s" => \$lopts {' ondemand-resolver-result' }, # -ondemand-resolver-result ID
80+ " asd-tld=s" => \$lopts {' asd-tld' }, # -asd-tld DOMAIN1,DOMAIN2 | input.txt
81+ " asd-ns=s" => \$lopts {' asd-ns' }, # -asd-ns DOMAIN1,DOMAIN2 | input.txt
82+ " asd-task=s" => \$lopts {' asd-task' }, # -asd-task TASKID
7883) or exit (0);
7984
8085if ($lopts {help }) {
@@ -211,6 +216,11 @@ elsif ($lopts{discovery}) {
211216elsif ($lopts {search }) {
212217 my $params ;
213218 $params -> {size } = $lopts {size } if defined ($lopts {size });
219+ if ($lopts {count }) {
220+ $params -> {size } = 1;
221+ $lopts {maxpage } = 1;
222+ $params -> {count } = 1;
223+ }
214224 $oa -> search($oql , 1, $lopts {maxpage }, $params , $opp_perl_cb , $opl ); # But is also in config()
215225}
216226elsif ($lopts {postsearch }) {
@@ -222,6 +232,11 @@ elsif ($lopts{export}) {
222232 my $params ;
223233 $oa -> export($oql , $params , $opp_json_cb , $opl );
224234}
235+ elsif ($lopts {postexport }) {
236+ my $params ;
237+ $params -> {size } = $lopts {size } if defined ($lopts {size });
238+ $oa -> post_export($oql , $params , $opp_json_cb , $opl ); # But is also in config()
239+ }
225240elsif ($lopts {' alert-list' }) {
226241 $oa -> alert_list($opp_perl_cb , $opl );
227242}
@@ -279,6 +294,13 @@ elsif (defined($lopts{'ondemand-scope-ip-bulk'})) {
279294 $param -> {import } = $lopts {import } if defined $lopts {import };
280295 $oa -> ondemand_scope_ip_bulk($v , $param , $opp_perl_cb , $opl );
281296}
297+ elsif (defined ($lopts {' ondemand-scope-port' })) {
298+ my $v = $lopts {' ondemand-scope-port' };
299+ my $param ;
300+ $param -> {maxscantime } = 24*60*60; # 24-hours forced
301+ $param -> {import } = $lopts {import } if defined $lopts {import };
302+ $oa -> ondemand_scope_port($v , $param , $opp_perl_cb , $opl );
303+ }
282304elsif (defined ($lopts {' ondemand-scope-domain' })) {
283305 my $v = $lopts {' ondemand-scope-domain' };
284306 my $param ;
@@ -353,6 +375,56 @@ elsif (defined($lopts{'ondemand-resolver-result'})) {
353375 $oa -> ondemand_resolver_result($v , $param , $opp_perl_cb , $opl );
354376 }
355377}
378+ elsif (defined ($lopts {' asd-tld' })) {
379+ my $v = $lopts {' asd-tld' };
380+ my $param ;
381+ $param -> {aslines } = $lopts {aslines } if defined $lopts {aslines };
382+ $param -> {trusted } = $lopts {trusted } if defined $lopts {trusted };
383+ if (-f $v ) { # If its a file, we create the list of values to push
384+ my $list = $oa -> asd_load_input($v );
385+ unless (defined ($list ) && @$list ) {
386+ print STDERR " VERBOSE: asd_load_input: failed from bad content or empty content\n " ;
387+ exit (1);
388+ }
389+ $v = $list ;
390+ }
391+ if ($param -> {aslines }) {
392+ $oa -> asd_tld($v , $param , $opp_json_cb , $opl );
393+ }
394+ else {
395+ $oa -> asd_tld($v , $param , $opp_perl_cb , $opl );
396+ }
397+ }
398+ elsif (defined ($lopts {' asd-ns' })) {
399+ my $v = $lopts {' asd-ns' };
400+ my $param ;
401+ $param -> {aslines } = $lopts {aslines } if defined $lopts {aslines };
402+ if (-f $v ) { # If its a file, we create the list of values to push
403+ my $list = $oa -> asd_load_input($v );
404+ unless (defined ($list ) && @$list ) {
405+ print STDERR " VERBOSE: asd_load_input: failed from bad content or empty content\n " ;
406+ exit (1);
407+ }
408+ $v = $list ;
409+ }
410+ if ($param -> {aslines }) {
411+ $oa -> asd_ns($v , $param , $opp_json_cb , $opl );
412+ }
413+ else {
414+ $oa -> asd_ns($v , $param , $opp_perl_cb , $opl );
415+ }
416+ }
417+ elsif (defined ($lopts {' asd-task' })) {
418+ my $v = $lopts {' asd-task' };
419+ my $param ;
420+ $param -> {aslines } = $lopts {aslines } if defined $lopts {aslines };
421+ if ($param -> {aslines }) {
422+ $oa -> asd_task($v , $param , $opp_json_cb , $opl );
423+ }
424+ else {
425+ $oa -> asd_task($v , $param , $opp_perl_cb , $opl );
426+ }
427+ }
356428else {
357429 usage();
358430}
@@ -370,6 +442,7 @@ Usage: onyphe [options] -user
370442 onyphe [options] -search 'OQL'
371443 onyphe [options] -postsearch 'OQL'
372444 onyphe [options] -export 'OQL'
445+ onyphe [options] -postexport 'OQL'
373446 onyphe [options] -discovery datascan 'input.txt'
374447 onyphe [options] -simple datascan 'IP'
375448 onyphe [options] -simple-best whois 'IP'
@@ -401,13 +474,15 @@ API options:
401474 -riskscan <0|1> turn off/on riskscan detection step in scan mode
402475 -asm <0|1> turn off/on ASM step in scan mode
403476 -import <0|1> turn off/on import of results into ONYPHE
477+ -trusted <0|1> turn off/on trusted results from ONYPHE ASD APIs
404478
405479APIs:
406480
407481 -user '| OPP' get information on your license
408482 -search 'OQL | OPP' use Search API for query
409483 -postsearch 'OQL | OPP' use Search API for query, POST version
410484 -export 'OQL | OPP' use Export API for query
485+ -postexport 'OQL | OPP' use Export API for query, POST version
411486 -discovery CATEGORY 'input.txt | OPP' use Discovery API on CATEGORY for query
412487 -simple CATEGORY 'OQL | OPP' use Simple API on CATEGORY for query
413488 -simple-best CATEGORY 'OQL | OPP' use Simple Best API on CATEGORY for query
@@ -426,9 +501,13 @@ APIs:
426501 -ondemand-scope-domain-bulk 'input.txt' use Ondemand Scope Domain Bulk API to launch a scan against a given list of domain from an input file
427502 -ondemand-scope-hostname 'HOSTNAME' use Ondemand Scope Hostname API to launch a scan against given hostname
428503 -ondemand-scope-hostname-bulk 'input.txt' use Ondemand Scope Hostname Bulk API to launch a scan against a given list of hostname from an input file
504+ -ondemand-scope-port PORT use Ondemand Scope Port API to launch a scan against a given port on full IPv4 address space
429505 -ondemand-scope-result \$ scan_id use Ondemand Scope Result API with Scan ID
430506 -ondemand-resolver-domain 'DOMAIN' use Ondemand Resolver Domain API to launch a DNS enumeration and resolution against given domain
431507 -ondemand-resolver-result \$ scan_id use Ondemand Resolver Result API with Scan ID
508+ -asd-tld DOMAIN1,DOMAIN2,...|input.txt use ASD Tld API to find related domains by TLDs
509+ -asd-ns DOMAIN1,DOMAIN2,...|input.txt use ASD Ns API to find related domains by using nameservers
510+ -asd-task TASKID use ASD Task API to retrieve an ASD Task results
432511
433512EOF
434513;
0 commit comments