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

Handle extraction from all files in a directory #12

Closed
deadbits opened this issue Jul 28, 2018 · 2 comments · Fixed by #64
Closed

Handle extraction from all files in a directory #12

deadbits opened this issue Jul 28, 2018 · 2 comments · Fixed by #64
Assignees
Labels
enhancement New feature or request
Projects

Comments

@deadbits
Copy link

It'd be great to be able to provide a directory path to iocextract and have it iterate over all files, extracting IOC's from each as it goes.

for example, i have a directory of malicious SLK files and I want to quickly dump all the URLs. right now I have to use something like for i in ls; do iocextract --extract-urls --input $i; done

passing a dir to --input obviously throws an exception due to the arguments use to io:

 File "iocextract.py", line 442, in <lambda>
    parser.add_argument('--input', type=lambda x: io.open(x, 'r', encoding='utf-8', errors='ignore'),
IOError: [Errno 21] Is a directory: '/home/adam/research/malware/campaigns/slk-droppers'

Would you be okay with re-working --input to accept a file as input, stdin as an optional positional argument, and add a --dir argument for folders? I can put in a PR if so - or if you have any other suggestions for this use case, that'd be great :D

@rshipp rshipp added the enhancement New feature or request label Jul 28, 2018
@rshipp
Copy link
Contributor

rshipp commented Jul 28, 2018

Go for it. The cli is an afterthought on my end, I only use the library - so if there's anything you want to change to make it fit your workflow better, its fine with me.

One note - the --input flag used to use the argparse builtins for file handling, which supports - as stdin, but I had to change to the current lambda because argparse dies when fed binary input. This piece can be fragile moving between Python 2/3 too, because of the unicode/str/bytes differences.

@rshipp rshipp added this to To do in Issues via automation Jul 28, 2018
@deadbits
Copy link
Author

deadbits commented Aug 1, 2018

Sounds good. thanks for the input too on potential argparse quirks - good to know ahead of time. I'll play around a bit so nothing breaks and throw in a PR

Personally I very much use the script instead of the library. I end up using little oneliners to act as my directory input currently... if adding the new input gives me too much trouble I might just close this and stick to shell scripting unless I see anyone else who also really wants this. If it's just really for myself I'll deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Issues
  
To do
Development

Successfully merging a pull request may close this issue.

3 participants