Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resume option #538

Merged
merged 8 commits into from
Aug 21, 2023
Merged

add resume option #538

merged 8 commits into from
Aug 21, 2023

Conversation

dogancanbakir
Copy link
Member

This PR adds -resume option to recover from an early exit or ungraceful termination. Closing #374.

@dogancanbakir dogancanbakir linked an issue Jul 28, 2023 that may be closed by this pull request
@dogancanbakir dogancanbakir self-assigned this Jul 28, 2023
Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting struct instead of bool in map value field type

pkg/engine/common/base.go Outdated Show resolved Hide resolved
Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to rethink this approach a bit. Using the inflight urls as seed root urls lead to start n instances equal to the number of urls and revisiting the same nodes multiple times (I'm using a simplehttpserver pointed to my go folder):

$ echo http://0.0.0.0:46661/  | go run . -resume /home/marco/.config/katana/resume-cj1sss13gitq4gtfs8mg.cfg
[INF] Resuming from save checkpoint

   __        __                
  / /_____ _/ /____ ____  ___ _
 /  '_/ _  / __/ _  / _ \/ _  /
/_/\_\\_,_/\__/\_,_/_//_/\_,_/                                                   

                projectdiscovery.io

[INF] Current katana version v1.0.3-dev (development)
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/nuclei
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/gopkgs
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/go-outline
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/dlv
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/simplehttpserver
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/naabu
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/staticcheck
[INF] Started standard crawling for => http://0.0.0.0:46661/
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/gopls
[INF] Started standard crawling for => http://0.0.0.0:46661/bin/dlv-dap
http://0.0.0.0:46661/src/
http://0.0.0.0:46661/pkg/
http://0.0.0.0:46661/src/
http://0.0.0.0:46661/src/

I think that we might need to track original root url and then just enqueue navigation requests for the same root url instance.

@ehsandeep ehsandeep added the Type: Enhancement Most issues will probably ask for additions or changes. label Jul 31, 2023
Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As tracking in-flight URLs turned out to be quite challenging with list based approach, let's simplify this by tracking only the input items processed/in-flight/todo. For example the following input:

http://192.168.5.36:8000/pkg/
http://192.168.5.36:8000/src/
http://192.168.5.36:8000/bin/

With the execution interrupted at half:

$ cat list.txt  | go run . -c 1 -p 1
[INF] Started standard crawling for => http://192.168.5.36:8000/pkg/
...
[INF] Started standard crawling for => http://192.168.5.36:8000/src/
...
^C

So with the following situation:

http://192.168.5.36:8000/pkg/ # completed
http://192.168.5.36:8000/src/ # in-flight
http://192.168.5.36:8000/bin/ # todo

Should start processing from the beginning only those in-flight/todo http://192.168.5.36:8000/src/ and http://192.168.5.36:8000/bin/ )

Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

The elaboration starts from inflight incomplete items:

$ cat list.txt
http://192.168.5.36:8000/pkg/
http://192.168.5.36:8000/src/
http://192.168.5.36:8000/bin/
$ cat list.txt  | go run . -c 1 -p 1
...
[INF] Started standard crawling for => http://192.168.5.36:8000/src/
^C[INF] - Ctrl+C pressed in Terminal
$ cat list.txt  | go run . -c 1 -p 1 -resume /Users/xxx/.config/katana/resume-xxxxxxx.cfg
...
[INF] Started standard crawling for => http://192.168.5.36:8000/src/
...

Note: only fully completed items are skipped

@ehsandeep ehsandeep merged commit 429a4ae into dev Aug 21, 2023
13 checks passed
@ehsandeep ehsandeep deleted the add_resume_option branch August 21, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add stop/resume support
3 participants