pentestgeek/jigsaw — pull request #8 by dougsko (2013-07-23 16:22:09+00:00)
Title: added check to see if ARGV is empty. clears it out if not

If you add an argument to the command without a switch, it causes ruby to crash. I just added in a check to clear out ARGV after ```args.parse!(ARGV)``` to fix it. This is what the bug looks like:

```
$ ./jigsaw.rb -i 215043 foo
Your target has 23 domain/s:

[1] - adwords.google.com
[2] - coppermountain.com
[3] - email.mot.com
[4] - google.ca
[5] - google.co.nz
[6] - google.co.uk
[7] - google.com
[8] - google.ie
[9] - mot.com
[10] - motorola-labs.com
[11] - motorola.ca
[12] - motorola.com
[13] - motorola.com.sg
[14] - motorolacareers.com
[15] - netplane.com
[16] - orthogonsystems.com
[17] - quantumbridge.com
[18] - quickoffice.com
[19] - sickdimension.com
[20] - sites.google.com
[21] - symbol.com
[22] - tutsys.com
[23] - youtube.com

Enter the number of the domain to use for crafting emails: Error setting domain: No such file or directory - foo
Found 696 records in the Sales department.
7
Your target has 23 domain/s:

[1] - adwords.google.com
[2] - coppermountain.com
[3] - email.mot.com
[4] - google.ca
[5] - google.co.nz
[6] - google.co.uk
[7] - google.com
[8] - google.ie
[9] - mot.com
[10] - motorola-labs.com
[11] - motorola.ca
[12] - motorola.com
[13] - motorola.com.sg
[14] - motorolacareers.com
[15] - netplane.com
[16] - orthogonsystems.com
[17] - quantumbridge.com
[18] - quickoffice.com
[19] - sickdimension.com
[20] - sites.google.com
[21] - symbol.com
[22] - tutsys.com
[23] - youtube.com

Enter the number of the domain to use for crafting emails: ./jigsaw.rb:125: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

-- control frame ----------
c:0006 p:---- s:0026 b:0026 l:000025 d:000025 CFUNC :gets
c:0005 p:---- s:0024 b:0024 l:000023 d:000023 CFUNC :gets
c:0004 p:0200 s:0021 b:0021 l:000020 d:000020 METHOD ./jigsaw.rb:125
c:0003 p:0092 s:0013 b:0013 l:0011a8 d:000012 BLOCK ./jigsaw.rb:208
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
./jigsaw.rb:208:in `block in get_number_of_records'
./jigsaw.rb:125:in `get_company_domain'
./jigsaw.rb:125:in `gets'
./jigsaw.rb:125:in `gets'

-- C level backtrace information -------------------------------------------
/usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x5f) [0x7f5058968b1f]
/usr/lib/libruby-1.9.1.so.1.9(+0x5b304) [0x7f5058874304]
/usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xb3) [0x7f5058874473]
/usr/lib/libruby-1.9.1.so.1.9(+0xefb35) [0x7f5058908b35]
/lib/libpthread.so.0(+0xeff0) [0x7f505860bff0]
/usr/lib/libruby-1.9.1.so.1.9(+0x7cfd3) [0x7f5058895fd3]
/usr/lib/libruby-1.9.1.so.1.9(+0x81de0) [0x7f505889ade0]
/usr/lib/libruby-1.9.1.so.1.9(+0x81e66) [0x7f505889ae66]
/usr/lib/libruby-1.9.1.so.1.9(+0x147b7d) [0x7f5058960b7d]
/usr/lib/libruby-1.9.1.so.1.9(+0x148be8) [0x7f5058961be8]
/usr/lib/libruby-1.9.1.so.1.9(+0x140dd0) [0x7f5058959dd0]
/usr/lib/libruby-1.9.1.so.1.9(+0x1457f1) [0x7f505895e7f1]
/usr/lib/libruby-1.9.1.so.1.9(rb_vm_invoke_proc+0x2f2) [0x7f50589606c2]
/usr/lib/libruby-1.9.1.so.1.9(+0x154731) [0x7f505896d731]
/usr/lib/libruby-1.9.1.so.1.9(+0x15478a) [0x7f505896d78a]
/lib/libpthread.so.0(+0x68ca) [0x7f50586038ca]
/lib/libc.so.6(clone+0x6d) [0x7f5057aa5b6d]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
```