Compare commits

..

470 commits
v8.8 ... master

Author SHA1 Message Date
van Hauser
96b42617d7
Merge pull request #1021 from lhywk/fix/null-check-start_redis
Some checks failed
release / Build the docker image (push) Has been cancelled
Fix Add NULL check to prevent NULL pointer dereference in start_redis( )
2025-07-03 09:56:21 +02:00
lhywk
cbd08d5702 Add NULL check after hydra_receive_line() in start_redis() 2025-07-03 05:07:27 +00:00
van Hauser
8e6ccbba8e
Merge pull request #1020 from xh4vm/master
Some checks failed
release / Build the docker image (push) Has been cancelled
POP3 CAPA response fix
2025-06-29 17:00:04 +02:00
xh4vm
5ddee91edc feat: pop3 capa fix 2025-06-29 19:22:31 +05:00
van Hauser
e762093915
Merge pull request #1019 from oss-belobog/fix-leak
Fix several memory leaks
2025-06-11 10:41:14 +02:00
oss-belobog
f80dc5aa02 fix several memory leaks 2025-06-04 00:54:30 +08:00
van Hauser
b763262c4a
Merge pull request #1007 from motypi/use-library-for-mssql
Use library for mssql
2025-04-04 14:19:04 +02:00
van Hauser
5dbcfdc362
Merge pull request #1009 from iskanred/master
Fix typo in README: lenght
2025-04-04 14:18:17 +02:00
iskanred
21262626e0 Fix typo in README: lenght 2025-04-01 04:59:28 +03:00
motypi
1af1682414 delete tds7 function and print warning 2025-03-24 10:25:04 +01:00
motypi
b5eb38e48f mixed TDS7 into old function 2025-03-24 09:05:03 +01:00
motypi
5f706c7071 freetds install in README 2025-03-19 20:35:29 +01:00
motypi
bc48f7625b added dbclose() and dbexit() in mssql module 2025-03-19 20:17:39 +01:00
motypi
369374b166 revert Makefile 2025-03-19 12:14:50 +01:00
motypi
17c6228f7b generated Makefile 2025-03-19 08:01:10 +01:00
motypi
3635dff5ff handle libraries accommodate old version of TDS 2025-03-19 07:41:46 +01:00
van Hauser
c57df67aeb
Merge pull request #1005 from xh4vm/http-misc-targets
feat: added paths for brute force and additional settings
2025-03-18 16:05:37 +01:00
motypi
3c233fdbc0 Used freetds to use TDSv7. First working version. 2025-03-18 16:05:08 +01:00
xh4vm
b81105f6af fix: hydra-http-form documentation 2025-03-18 17:35:41 +05:00
xh4vm
aae8baae83 fix: hydra-http documentation 2025-03-18 17:32:56 +05:00
xh4vm
ba45db1496 feat: added documentation 2025-03-14 19:28:04 +05:00
xh4vm
ad286790ca feat: integration with http[s]-* 2025-03-13 12:26:57 +05:00
van Hauser
9bf9f8ba76
Merge pull request #1003 from motypi/add-distributed-computing
Add distributed computing
2025-03-12 10:52:40 +01:00
motypi
b8ea180d85 unique segment filename 2025-03-12 10:38:25 +01:00
motypi
74b37e24c8 unique segment filename 2025-03-12 10:37:01 +01:00
xh4vm
79f7d52ba2 feat: added paths for brute force and additional settings for all targets from the file 2025-03-12 13:07:12 +05:00
van Hauser
7bf582699d
Merge pull request #1004 from xh4vm/postgres-custom-port
feat: added the ability to brute force a custom port
2025-03-11 18:06:53 +01:00
xh4vm
4fad67d307 feat: added the ability to brute force a custom port 2025-03-11 18:42:09 +05:00
motypi
5eea263707 remove segment files at exit 2025-03-11 14:10:52 +01:00
motypi
8faf1984d8 removed debug messages 2025-03-10 23:02:55 +01:00
motypi
f632c7231e added help for -D option 2025-03-10 22:41:50 +01:00
motypi
2c50bb8e6d added wordlist (password,login,colonfile) segmentation on the fly using cmd option -D 2025-03-10 13:58:09 +01:00
motypi
a8f80debed added variables and applied skipping function 2025-03-04 10:34:23 +01:00
motypi
3cc53fe778 created skip_password function 2025-03-03 13:00:37 +01:00
van Hauser
6aaeee97a3
Merge pull request #914 from tothi/fix-smb-pw-expiry
fix smb password expired vs account expired confusion
2025-02-18 09:20:09 +01:00
van Hauser
4fb430b18e
Merge pull request #947 from Proto1337/master
Bump Debian version in Dockerfile to Bookworm
2025-02-18 09:19:16 +01:00
van Hauser
e4367b2f13
Merge pull request #970 from ccc-aaa/master
Fix compile errors when compiling against freerdp3
2025-02-18 09:18:43 +01:00
van Hauser
b19b39c575
Merge pull request #1001 from motypi/add-http-multipart-format
Add http multipart format
2025-02-10 16:09:52 +01:00
motypi
db099fcdac cleaning code 2025-02-10 14:57:07 +01:00
motypi
ba9a3ba8de add help for multipart mode, remove junk files 2025-02-10 10:37:17 +01:00
motypi
65c897da68 multipart feature finished 2025-02-07 14:27:04 +01:00
Imane Khouani
80a11bb1e0 no comments 2025-02-06 17:54:26 +01:00
Imane Khouani
6cca92477e no comments 2025-02-06 17:48:39 +01:00
Imane Khouani
5e01d0d4e5 build multipart function completed 2025-02-06 17:38:59 +01:00
Imane Khouani
373da88a7e build multipart function completed 2025-02-06 17:21:47 +01:00
motypi
57216f5ce6 added multipart_mode flag, build function incomplete 2025-02-06 16:26:53 +01:00
motypi
71c846d14f started on the build_multipart_body function 2025-02-06 14:11:48 +01:00
motypi
0b7d3c4bbf integrated multipart in start_http_form, created multipart flag 2025-02-05 23:18:42 +01:00
a12092
7545077a16 Unify settings access between freerdp 2 and 3
use `instance->context->settings` in both versions.
2024-08-13 14:19:14 +08:00
a12092
eb7ab3907b Adapt with freerdp changes
FreeRDP/FreeRDP#7738
use fields under rdpContext instead of freerdp

FreeRDP/FreeRDP@5f8100
removes reference to MaxTimeInCheckLoop since FreeRDP has dropped this
field after migrating away from blocking poll loop.
2024-08-13 13:40:20 +08:00
Umut Yilmaz
eaf17e9d5d
Bump Dockerfile Base Image
* Debian Buster -> Debian Bookworm
2024-05-07 21:53:13 +02:00
vanhauser-thc
03cdc31f98 update oracle url 2024-04-01 14:18:47 +02:00
tothi
82fd1a3ca0
Update hydra-smb.c
fixed logging (if found -> hydra_report to stdout with Information instead of Error)
2024-02-29 02:52:00 +01:00
vanhauser-thc
8c4165a83b show form 401 option 2023-12-07 15:54:02 +01:00
vanhauser-thc
438e4fa537 fix 2023-12-05 09:36:16 +01:00
van Hauser
02e0c8ce3e
Merge pull request #912 from Hatsumi-FR/fix/redefinition-of-tmp
Fix "make" error
2023-12-05 09:32:17 +01:00
van Hauser
fb090d4bf9
Merge pull request #915 from tothi/add-ssh-legacy-ciphers
add legacy SSH ciphers support
2023-12-05 09:31:46 +01:00
TÓTH István
9269d54ca4 add legacy SSH ciphers support 2023-12-05 01:19:55 +01:00
TÓTH István
48c1e20985 fix smb password expired vs account expired confusion 2023-12-05 01:13:11 +01:00
Hatsumi-FR
15b1f93903 Fix "make" error
Variable 'tmp' was moved to a higher scope in the parse_options function of hydra-http-form.c. This change was necessary to prevent duplicate declarations in the different switch case blocks. This PR fix "make" error : error: redefinition of ‘tmp’
2023-12-03 14:11:19 +01:00
van Hauser
e950212789
Merge pull request #898 from andraxin/patch-1
Update hydra-http-form.c
2023-11-29 16:11:23 +01:00
andraxin
1dce42a0cc
Update hydra-http-form.c
Fix handling web forms that may return 401.
2023-09-29 00:06:49 +02:00
vanhauser-thc
16b424af4d support -W for modules that use libarries 2023-08-13 13:07:10 +02:00
van Hauser
b4a2b0b4ef
Merge pull request #882 from danielvandenberg95/master-1
Allow HTTP-POST with F=403
2023-08-13 10:47:00 +00:00
Daniël van den Berg
d2363dc99e
Allow HTTP-POST with F=403
I had a site which returns 200OK, but a json containing 403. Get results in "invalid api call". Allow using F= with post.
2023-08-10 16:25:37 +02:00
vanhauser-thc
568ef74e0d nits 2023-07-21 10:44:38 +02:00
van Hauser
93abd60fc9
Merge pull request #869 from R-Rothrock/master
Fixed #868 on vanhauser-thc/thc-hydra
2023-07-12 15:43:10 +02:00
Roan Rothrock
fb964fc113 Fixed #868 on vanhauser-thc/thc-hydra 2023-07-11 10:15:24 -05:00
van Hauser
e5c9eb6ab7
Merge pull request #867 from CoenTempelaars/issue-863
fix replacement of user/pass placeholders in http header
2023-07-08 09:58:05 +02:00
Coen Tempelaars
310068c9ca fix replacement of user/pass placeholders in http header 2023-07-08 09:43:38 +02:00
vanhauser-thc
8a2df9b8f2 9.6dev 2023-06-30 17:21:44 +02:00
van Hauser
b8feed0e5d
Merge pull request #861 from bearxy123/master
fix memory leaks for hydra-http-form.c
2023-06-30 18:16:41 +03:00
xiongyi
bb0fc93539 fix memory leaks for hydra-http-form.c
Signed-off-by: xiongyi <xiongyi@uniontech.com>
2023-06-27 17:45:38 +08:00
van Hauser
888da899f9
Merge pull request #860 from neo-one0873/patch-1
fix: array proxy_string_port may out of bound
2023-06-27 09:40:29 +03:00
neo-one0873
58256c8b4f
fix: array proxy_string_port may out of bound
when proxy_count=64, array proxy_string_port , proxy_string_ip, etc. may out of bound.
2023-06-27 10:41:16 +08:00
vanhauser-thc
28f073fd79 fix pw-inspector 2023-06-24 12:03:03 +02:00
vanhauser-thc
714b051867 v9.5 release 2023-06-12 10:05:41 +02:00
vanhauser-thc
377ac86652 v9.6 release 2023-06-12 10:03:35 +02:00
van Hauser
2566faee17
Merge pull request #853 from leo0liver/fix-rdp-0002000f
fix rdp response 0002000f not recognised as a failed attempt
2023-06-10 10:01:08 +03:00
leo
a0565e1abe fix rdp response 0002000f not recognised as a failed attempt 2023-06-10 18:30:20 +12:00
van Hauser
2073f04850
Merge pull request #845 from bugith/master
Update README
2023-05-14 13:09:30 +03:00
bugith
01efa98ded
Update README
-x syntax with special characters
2023-05-14 12:03:43 +02:00
vanhauser-thc
75b7b52da9 fix proxy support for http-form 2023-03-13 09:23:55 +01:00
vanhauser-thc
4ae7a365e9 fix http form help output 2023-03-06 10:35:03 +01:00
van Hauser
bae8fc40c0
Merge pull request #827 from xd0419/master
edit mongodb moudle error
2023-03-02 14:50:43 +01:00
xd0419
97cae4633c edit mongodb moudle error 2023-03-01 22:08:53 +08:00
van Hauser
a22c55cdbe
Merge pull request #822 from mashaz/develop
fix: program stuck when mongodb user is empty
2023-02-13 07:20:33 +01:00
van Hauser
27bf32f6ad
Merge pull request #817 from fweimer-rh/c99
Various C99 compatibility fixes
2023-01-18 16:58:18 +01:00
Florian Weimer
a41d10dc8c Various C99 compatibility fixes
strrchr is declared in <strings.h>, not <string.h>.

_GNU_SOURCE needs to be defined before any glibc headers are included,
otherwise it is not effective.

Also patch some old autoconf-internal issues in the hydra-gtk
configure script.
2023-01-18 16:30:24 +01:00
vanhauser-thc
c6a3f77476 welcome 2023 2023-01-03 11:47:45 +01:00
van Hauser
985046ae13
Merge pull request #809 from ring04h/master
rdp: support hydra waittime
2022-12-06 12:12:09 +01:00
ringzero
d830ac795e rdp implementing-w and -W support 2022-12-06 09:41:04 +08:00
ringzero
eb939baaa5 rdp: support hydra waittime 2022-12-05 20:12:56 +08:00
van Hauser
68d01e9ea3
Merge pull request #807 from ring04h/master
freerdp tls-seclevel to 0
2022-12-04 15:31:04 +01:00
ringzero
e9698cd530 freerdp tls-seclevel to 0 2022-12-04 16:13:47 +08:00
mashaz
1284671031 fix: error when mongodb user is empty 2022-11-15 15:01:58 +08:00
vanhauser-thc
4778a398d9 fix man page 2022-11-09 12:08:34 +01:00
vanhauser-thc
972039b3ae fix help 2022-11-04 10:56:56 +01:00
vanhauser-thc
feaab90b1f fix smtp 2022-11-03 17:05:41 +01:00
vanhauser-thc
8fb5f5e2b4 update changelog 2022-10-14 10:31:21 +02:00
vanhauser-thc
04204f7d9b fix attempt for smb2 2022-10-14 10:29:22 +02:00
vanhauser-thc
5ab0b95f8f fix attempt for smb2 2022-10-14 10:23:19 +02:00
vanhauser-thc
8ddec0107b dockerfile fix 2022-10-13 17:28:39 +02:00
vanhauser-thc
882a1a3aac fix http-...-form help 2022-09-29 10:01:56 +02:00
van Hauser
3332b3c366
Merge pull request #786 from thesamesam/implicit-function-decl
Makefile.am: add -D_GNU_SOURCE for strcasestr
2022-09-10 10:51:54 +02:00
Sam James
613bd02264
Makefile.am: add -D_GNU_SOURCE for strcasestr
strcasestr is not a standard function and per
the man page, needs -D_GNU_SOURCE to be visible.

Fixes a build error:
```
hydra-rtsp.c:20:7: error: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Werror=implicit-function-declaration]
   20 |   if (strcasestr(s, "401 Unauthorized") != NULL) {
      |       ^~~~~~~~~~
      |       strcasecmp
```

Signed-off-by: Sam James <sam@gentoo.org>
2022-09-09 04:32:05 +01:00
vanhauser-thc
28aaa7bab9 v9.5-dev init 2022-09-08 10:33:59 +02:00
vanhauser-thc
45d2f2dd67 v9.4 release 2022-09-08 10:32:44 +02:00
vanhauser-thc
5cb9e50cc5 fix for http-form redirect 2022-08-04 09:20:06 +02:00
vanhauser-thc
697f408d41 license stuff 2022-07-18 17:59:18 +02:00
van Hauser
4c3c0d519b
Merge pull request #775 from vanhauser-thc/add-license-1
Create LICENSE.md
2022-07-18 17:57:21 +02:00
van Hauser
0eb19744df
Create LICENSE.md 2022-07-18 17:57:11 +02:00
vanhauser-thc
615e566e79 wait3 -> waitpid 2022-07-18 10:04:01 +02:00
vanhauser-thc
770c5c436e fix 2022-06-13 20:40:50 +02:00
vanhauser-thc
1835eac20a fix 2022-06-13 20:35:28 +02:00
vanhauser-thc
03a490133e fix 2022-06-13 20:15:35 +02:00
vanhauser-thc
ea1e64fa5d fix 2022-06-13 20:06:32 +02:00
vanhauser-thc
b2fe51dc7f fix 2022-06-13 19:56:31 +02:00
vanhauser-thc
72f5cfe67c fix 2022-06-13 19:52:13 +02:00
vanhauser-thc
77037ecbb6 docker image 2022-06-13 19:32:55 +02:00
van Hauser
c9555fb8c6
Merge pull request #767 from tarampampam/docker-image
Hydra docker image
2022-06-13 17:45:43 +02:00
van Hauser
63e3dce877
Update .github/workflows/release.yml
Co-authored-by: Paramtamtam <7326800+tarampampam@users.noreply.github.com>
2022-06-13 17:30:57 +02:00
Paramtamtam
d5e525bcb0
cleanup 2022-06-13 20:20:58 +05:00
van Hauser
705a6c180d
Update release.yml 2022-06-13 17:13:37 +02:00
van Hauser
26f97b54d5
Update Dockerfile 2022-06-13 17:09:43 +02:00
Paramtamtam
f90c4d24c6
Update release.yml 2022-06-13 19:40:11 +05:00
Paramtamtam
2dc4656d72
Docker env implemented 2022-06-13 18:07:55 +04:00
vanhauser-thc
b9a985fb56 fix wizard script 2022-05-11 11:27:39 +02:00
vanhauser-thc
63e2836e91 fix option parsing 2022-05-05 12:45:47 +02:00
vanhauser-thc
7591dcc60b add 2= optional parameter to http-post-form 2022-05-05 09:33:49 +02:00
vanhauser-thc
a1cbbe1432 more variance for rtsp, code format 2022-04-26 12:09:03 +02:00
van Hauser
73029ac1a5
Merge pull request #744 from Teemperor/FixMemoryLeak
Fix memory leak in radmin2
2022-04-18 13:24:25 +02:00
vanhauser-thc
d95a89c384 no .md 2022-04-18 13:21:45 +02:00
Raphael Isemann
64ca3aead2 Fix memory leak in radmin2
`msg` is calloc'd a few lines above via `msg = buffer2message(buffer);`.
The check afterwards either exits the process on success or restarts the
loop without free'ing `msg`.
2022-04-11 18:27:28 +02:00
vanhauser-thc
354d9734af rtsp support 200 ok for auth check 2022-03-19 13:47:42 +01:00
vanhauser-thc
584be39d13 debug 2022-03-18 10:48:52 +01:00
vanhauser-thc
7dfedbb43a rtsp fix 2022-03-17 11:25:22 +01:00
vanhauser-thc
59b96af734 rtsp fix 2022-03-17 11:25:14 +01:00
vanhauser-thc
c82e5d51c5 switch to pcre2 2022-03-01 14:56:05 +01:00
vanhauser-thc
330e910a02 try redo fix 2022-02-21 14:18:29 +01:00
van Hauser
d887973533
Merge pull request #723 from Yisus7u7/master
hydra-gtk: add support for termux path
2022-02-14 12:56:59 +01:00
Yisus7u7
280988bfe6 hydra-gtk: add support for termux path 2022-02-11 11:23:24 -05:00
vanhauser-thc
e5996654ed fix return 2022-02-06 11:59:08 +01:00
vanhauser-thc
9ac9f7010e v9.4-dev init 2022-02-03 10:36:43 +01:00
vanhauser-thc
58b8ede906 9.3 release 2022-02-03 10:34:26 +01:00
vanhauser-thc
9cf065f06e error exit, restore write fix 2022-02-03 10:32:20 +01:00
van Hauser
dc871da59a
Merge pull request #718 from dbungert/openssl3-limits
configure: openssl / memcached build fix
2022-02-01 10:00:15 +01:00
Dan Bungert
e40b0dc252 configure: openssl / memcached build fix
On Debian/Ubuntu, compilation against openssl 3.0 causes a failure to
find INT_MAX, despite the openssl headers including limits.h.  However,
the fact that the libmemcached-dev package provides both
/usr/include/libmemcached{,-1.0} directories, both of which contain
memcached.h, mean that MCACHED_IPATH ends up set to the libmemcached-1.0
one, which contains a limits.h, which shadows /usr/include/limits.h.
Don't do that.
2022-01-31 14:41:32 -07:00
vanhauser-thc
e9140e5434 fix 2022-01-23 19:33:28 +01:00
vanhauser-thc
6d5fa802a2 citation 2022-01-23 16:33:22 +01:00
vanhauser-thc
1edef892f6 fix disappearing targets 2022-01-19 13:00:57 +01:00
vanhauser-thc
5a451ba541 http-form: no empty headers 2022-01-12 10:27:58 +01:00
vanhauser-thc
02ae72c7e7 dont exit after find with -C 2022-01-12 10:14:57 +01:00
vanhauser-thc
e11e007400 make strip optional 2022-01-11 13:50:47 +01:00
vanhauser-thc
c61fe26d16 fix http with proxy + port usage 2022-01-11 10:19:04 +01:00
van Hauser
23c86c45d5
Merge pull request #693 from Yisus7u7/patch-1
hydra-gtk: update to gtk3
2022-01-04 19:09:18 +01:00
vanhauser-thc
c637d1d7a0 welcome 2022 2022-01-01 00:51:04 +01:00
van Hauser
f2f931965e
Merge pull request #704 from ToraNova/master
fix mongodb module not using specified port
2022-01-01 00:39:43 +01:00
Toranova
4a1bb5117f fix mongodb module not using user specified port 2021-12-31 11:43:19 +08:00
Yisus7u7
52ce0772e8
hydra-gtk: update to gtk3
gtk3 is more modern and successor to the old gtk2
2021-11-22 13:55:36 -05:00
van Hauser
022790867d
Merge pull request #691 from Schweinepriester/patch-1
README: HTTP => HTTPS
2021-11-07 13:33:26 +01:00
Kai
f20ca77309
README: HTTP => HTTPS 2021-11-05 17:47:21 +01:00
vanhauser-thc
9b055287c0 fix -M ipv6 2021-11-01 14:13:51 +01:00
vanhauser-thc
13db28f9d2 rdp empty pw fix 2021-10-27 17:19:13 +02:00
vanhauser-thc
3e364483d2 support xcode 2021-10-20 16:29:52 +02:00
vanhauser-thc
89fbd9a44d debug 2021-10-14 10:14:42 +02:00
vanhauser-thc
b3bd068334 fix nits 2021-10-06 15:21:26 +02:00
vanhauser-thc
5cb14100f8 remove old option from help output 2021-08-31 09:37:06 +02:00
vanhauser-thc
67ef4c733f code format 2021-08-23 11:31:58 +02:00
van Hauser
09453c7be8
Merge pull request #681 from ultimaiiii/master
New CobaltStrike module
2021-08-23 11:28:32 +02:00
ultimaiiii
c9da867141
Move CS service to keep service list sorted 2021-08-21 17:12:40 +00:00
ultimaiiii
cb8fccda71
Rename MS to CS 2021-08-21 17:07:40 +00:00
ultimaiiii
63badb59af
Makefile fix 2021-08-20 23:18:46 +00:00
ultimaiiii
84c7b116db
New CobaltStrike module 2021-08-20 23:09:51 +00:00
vanhauser-thc
93cee75419 added make uninstall 2021-08-17 18:21:43 +02:00
van Hauser
403d00e897
Merge pull request #675 from horner/master
telnet detects password retries with same user
2021-08-06 11:54:26 +02:00
horner
edc910628f telnet detects password retries with same user 2021-08-05 13:52:18 -04:00
vanhauser-thc
cf20153655 smtp-enum: skip host on unsupported command 2021-08-01 11:06:15 +02:00
vanhauser-thc
b375bbc332 skip host when password is found on password-only checks 2021-06-29 12:15:03 +02:00
vanhauser-thc
0b1f3c5037 fix ssh for -M and ip/range 2021-06-29 12:04:36 +02:00
vanhauser-thc
93283091d0 sscanf change 2021-06-24 09:22:53 +02:00
vanhauser-thc
d3f784ab64 fix 2021-06-17 16:17:44 +02:00
vanhauser-thc
92ef7d7455 Revert "Merge pull request #666 from Yisus7u7/master"
This reverts commit 5b98a23140, reversing
changes made to a6784e4021.
2021-06-17 16:16:43 +02:00
van Hauser
5b98a23140
Merge pull request #666 from Yisus7u7/master
Add more files to GitHub pages
2021-06-17 16:13:18 +02:00
Yisus7u7
12dc488f3f Set theme jekyll-theme-slate 2021-06-16 22:55:27 -05:00
Yisus7u7
486a6bddde
Merge branch 'vanhauser-thc:master' into master 2021-06-16 16:31:08 -05:00
Yisus7u7
e02b0d41e5
Show repo info in image 2021-06-16 16:30:45 -05:00
Yisus7u7
3b9280da3a
Update README.md 2021-06-16 16:19:51 -05:00
Yisus7u7
cf325b0008
Update README.md 2021-06-16 16:18:57 -05:00
Yisus7u7
9fc4aabd6b
Update index.md 2021-06-16 16:15:08 -05:00
Yisus7u7
54c2e85d79
Update index.md 2021-06-16 16:13:24 -05:00
Yisus7u7
d260804d19
Update index.md 2021-06-16 16:12:12 -05:00
Yisus7u7
2d12a0df6a
Create index.md 2021-06-16 16:06:21 -05:00
Yisus7u7
bfdbeee1b2
Delete index.md 2021-06-16 15:54:06 -05:00
Yisus7u7
caf39e1542
Update README.md 2021-06-16 15:51:52 -05:00
Yisus7u7
be95247c69
Update README.md 2021-06-16 15:48:43 -05:00
Yisus7u7
0483351e6a
Create index.md 2021-06-16 15:44:42 -05:00
van Hauser
a6784e4021
Merge pull request #665 from Yisus7u7/master
Add GitHub pages service
2021-06-16 21:56:20 +02:00
Yisus7u7
27cab133fa
Delete index.md 2021-06-16 12:56:27 -05:00
Yisus7u7
24395ab478 Set theme jekyll-theme-midnight 2021-06-16 12:53:17 -05:00
Yisus7u7
55682bf69a Set theme jekyll-theme-modernist 2021-06-16 12:51:29 -05:00
Yisus7u7
7601493400
Create index.md 2021-06-16 12:50:01 -05:00
Yisus7u7
3450d87420
Update _config.yml 2021-06-16 12:46:23 -05:00
Yisus7u7
acd4bcf1a7 Set theme jekyll-theme-hacker 2021-06-16 12:43:58 -05:00
vanhauser-thc
bc9190d3dd fix 2021-06-16 11:18:12 +02:00
van Hauser
659ab10b14
Merge pull request #664 from Yisus7u7/master
Add termux setup file (android)
2021-06-16 11:16:07 +02:00
Yisus7u7
f1cc9e6cfb Specify in the INSTALL file the steps for Android (termux) 2021-06-16 03:06:40 -05:00
Yisus7u7
b7e77d7672 Specify in the INSTALL file the steps for Android (termux) 2021-06-16 03:03:31 -05:00
Yisus7u7
f12dc459c1 Specify in the INSTALL file the steps for Android (termux) 2021-06-16 03:01:07 -05:00
Yisus7u7
ef3c334671
Add termux setup file (android) 2021-06-16 02:30:45 -05:00
van Hauser
4de7595357
Merge pull request #662 from abhackerofficial/patch-1
Fixed data types.
2021-06-12 11:40:48 +02:00
ABHacker Official
19432a2173
Fixed data types. 2021-06-12 11:34:57 +05:30
van Hauser
fb0b2e030e
Merge pull request #651 from wj0s3ph/master
fix: skip user bug
2021-05-19 14:28:20 +02:00
wj0seph
221876598b fix: skip user bug
username can potentially be identical to the beginning of login_ptr
2021-05-19 20:18:49 +08:00
van Hauser
fc70daa757
Merge pull request #648 from sanmacorz/master
Changed index() to strchr()
2021-05-16 18:13:38 +02:00
sanmacorz
c81f0b97e7 Changed index() to strchr() 2021-05-12 12:22:48 -05:00
van Hauser
d6a42ace44
Merge pull request #638 from chris-pcguy/master
Fix logic bug
2021-04-26 21:10:33 +02:00
Christian Inci
a2d715b870 Fix logic bug
I can provide another patch version, which swaps the operands instead.

Signed-off-by: Christian Inci <chris.gh@broke-the-inter.net>
2021-04-26 20:56:22 +02:00
vanhauser-thc
dd8348bcf0 removed bad entries in dpl 2021-04-23 17:06:18 +02:00
vanhauser-thc
bd2f949b34 removed bad entries in dpl 2021-04-23 17:05:58 +02:00
vanhauser-thc
e7b3d09d00 removed bad entries in dpl 2021-04-23 16:07:50 +02:00
vanhauser-thc
593c5b151a fix macos + freerdp 2021-04-16 09:50:14 +02:00
vanhauser-thc
0749b9be9f malloc checks for restore 2021-04-15 11:35:34 +02:00
van Hauser
6381ab2cd3
Merge pull request #623 from xambroz/desktop-launcher
Desktop launcher
2021-03-24 08:51:26 +01:00
xambroz
5c9184061f
Install the desktop launcher for xhydra 2021-03-24 04:20:43 +01:00
xambroz
f250c8a191
Add the desktop launcher file 2021-03-24 03:52:36 +01:00
xambroz
b6dda7da81
Add transparent PNG file to be used as icon
Add transparent PNG file to be used as launcher icon. The original JPG is not transparent so it doesn't go well with window theme.
2021-03-24 03:50:55 +01:00
van Hauser
fd55766ea3
Merge pull request #621 from mexicarne/master
Fix assignment
2021-03-17 11:11:21 +01:00
Ruslan Makhmatkhanov
2ec0b164ca fix typo: comparison -> assignment 2021-03-17 13:04:24 +03:00
Ruslan Makhmatkhanov
2cbbc53692
Merge pull request #1 from vanhauser-thc/master
merge upstream
2021-03-17 13:02:07 +03:00
vanhauser-thc
fe930f4dd1 hydra 9.2 release 2021-03-15 18:52:54 +01:00
vanhauser-thc
cedbd0ddb2 indent 2021-03-11 14:00:40 +01:00
vanhauser-thc
f423875d90 remove rain mode 2021-03-11 14:00:00 +01:00
vanhauser-thc
ac2fd35b4f allow configure to pick up PKG_CONFIG 2021-02-19 09:19:05 +01:00
van Hauser
51da37bfd8 Update issue templates 2021-01-29 10:29:28 +01:00
van Hauser
0407699583 Update issue templates 2021-01-29 10:23:27 +01:00
van Hauser
09f6a71e84 2021 2021-01-01 12:20:49 +01:00
van Hauser
6364bf329b
Merge pull request #586 from kazkansouh/http-get-ipv6
http-get: ipv6 fix
2020-12-27 00:32:06 +01:00
Karim Kanso
37a0eeaabe www: normalise webtarget 2020-12-26 16:42:57 +00:00
van Hauser
08fc0fb2e2
Merge pull request #582 from e2002e/master
cleanup
2020-12-04 17:09:00 +01:00
y
3be6824fa2 cleanup 2020-12-04 12:50:46 +01:00
van Hauser
53290bb5cc
Merge pull request #569 from e2002e/master
Rain mode
2020-11-30 13:56:15 +01:00
van Hauser
469cafb639
Merge pull request #579 from kazkansouh/http-form-ipv6
http-form: ipv6 fix
2020-11-30 13:54:38 +01:00
e2002e
026ea7017e
Merge branch 'master' into master 2020-11-14 13:22:53 +00:00
owein
1a1bcf3855 uptodate with rainycrack 2020-11-14 14:20:00 +01:00
van Hauser
ea50c0a11f
Merge pull request #578 from kazkansouh/libsmbclient-miscptr
smb2: fix parsing of miscptr
2020-11-13 15:08:32 +01:00
owein
78b3358862 profound mangling 2020-11-12 17:06:53 +01:00
Karim Kanso
7f19248e34 resolve compiler warnings identified by gcc 9.3.0 2020-11-12 15:31:03 +00:00
Karim Kanso
981e19852b www-form: normalise webtarget 2020-11-12 15:31:03 +00:00
Karim Kanso
1df1d63c4f smb2: fix parsing of miscptr 2020-11-11 11:18:04 +00:00
owein
56d1726edf lqst commit 2020-11-09 19:41:00 +01:00
owein
b61dbacca9 up to last fix 2020-11-09 19:25:26 +01:00
owein
5e98fe23e7 see https://github.com/e2002e/zhou 2020-10-22 02:35:46 +02:00
van Hauser
c2260d2c5d
Merge pull request #574 from ddeka2910/master
Add architecture ppc64le to travis build
2020-10-20 17:53:21 +02:00
ddeka2910
2d0723b281
Add architecture ppc64le to travis build 2020-10-20 21:04:31 +05:30
ddeka2910
be654c6bac
As is 2020-10-20 21:02:17 +05:30
van Hauser
927ed229f2
Merge pull request #571 from g3offrey/master
html_encode the + character
2020-10-16 16:24:46 +02:00
van Hauser
631a61be8e fix http-post-form optional parameter parsing 2020-10-16 13:49:07 +02:00
owein
e69f06ef62 this should be the last commit 2020-10-10 19:49:02 +02:00
owein
9edbcd3c36 slight modif that fixes all 2020-10-10 18:52:04 +02:00
owein D
033c881f8f implement rain 2020-10-08 04:10:54 +02:00
owein D
fdb1c09c8e if current < 4 2020-10-05 14:45:40 +02:00
owein D
fc82b52505 working algo after a change 2020-10-05 14:37:04 +02:00
Geoffrey
bbab443f88 html_encode the + character 2020-10-02 16:44:10 +02:00
owein D
490bd3e7cd avoid negative values for the rotation variable 2020-09-30 10:19:10 +02:00
owein D
c65e3a26fc update efficient rain option 2020-09-29 21:01:13 +02:00
owein
3fa6d372cf fixed min length 2020-09-11 11:59:20 +02:00
owein
14ee7f2c83 typos again, too much copies and pastes... 2020-09-10 13:02:46 +02:00
e2002e
60a9924547
Merge branch 'master' into master 2020-09-10 12:52:26 +02:00
owein
2514335bf9 clean 2020-09-10 12:45:35 +02:00
owein
a6a87f11f4 fixed rotation broken due to a typo. 2020-09-10 10:57:06 +02:00
owein
fd8e83d0b1 done 2020-09-09 21:36:30 +02:00
owein
0e4913a7c1 help menu ok 2020-09-09 18:38:07 +02:00
owein
3742af00bb rebranded the bruteforce variation method 2020-09-09 18:34:40 +02:00
van Hauser
78387c1ab1
Merge pull request #553 from maaaaz/msys2
MSYS2 support
2020-08-16 13:43:23 +02:00
maaaaz
84e765d3a9 msys support 2020-08-16 04:10:38 -04:00
van Hauser
79fa70cfdb fix with gcc10 and overriden CFLAGS 2020-08-02 07:12:19 +02:00
van Hauser
0a17bf5f53 v9.1 release 2020-07-29 09:36:37 +02:00
van Hauser
a73cd388f8 fix PR 2020-07-07 18:43:53 +02:00
van Hauser
df475f1900
Merge pull request #538 from animetauren/master
Updating hydra support for freedrdp 3
2020-07-07 18:07:53 +02:00
Henry Robalino
fc196d7fc2
Updating freerdp logic to check v3 first
Updating the logic here to check for freerdpv3 first and if found do not check for freerdpv2. Also fixed paths for freerdpv2 paths.
Updated bash "or" to use "||" and "and" to use "&&" conditionals with proper POSIX specifications.
2020-07-07 11:25:09 -04:00
van Hauser
1ce502e754
Merge pull request #542 from Jab2870/https-help
Usage: Fix help for https-post-form and https-get-form
2020-06-26 17:39:04 +02:00
Jonathan Hodgson
5ec8a3e5e9 Makes change work on any sting starting with https
As per suggestion, the code now remvoes the 's' on any module starting
with https-
2020-06-26 15:31:20 +01:00
Jonathan Hodgson
62f06dce24 Usage: Fix help for https-post-form and https-get-form
Fixes issue #530
2020-06-26 11:49:18 +01:00
van Hauser
4ea2db2fe1
Merge pull request #541 from kazkansouh/oracle-fix
oracle: add success condition and fix skipped tries
2020-06-25 22:23:18 +02:00
Karim Kanso
11a96e5d32 oracle: add success condition and fix skipped tries 2020-06-25 20:21:16 +01:00
Henry Robalino
435ed44289
Adding step to makefile to fix Lib Symlinks 2020-06-16 10:19:16 -04:00
Henry Robalino
f5b3fe77d3
Fixing typo on xlibs path 2020-06-16 09:56:11 -04:00
Henry Robalino
54dd5667ff
Fixing XDEFINES
Trying to fix defines for freerdp
2020-06-16 09:53:24 -04:00
Henry Robalino
9c300ea820
Refactoring libfreerdp
Removing double entry of libfreerdp in hydra.c and hydra-rdp.c
2020-06-15 15:51:22 -04:00
Henry Robalino
70fb9e4fa5
Fixing logic that checks for rdp libraries
Fixed logic inside of configure to properly check for freedrdp2 if not found check for freerdp3, if found to skip freerdp3
2020-06-12 12:11:03 -04:00
Henry Robalino
fdc460c7fb
Fixing logic issue with hydra.c file
Did not do proper check for freerdp2 or freerdp3 modules
2020-06-12 11:32:25 -04:00
Henry Robalino
bc6e8aec41
Adding support to check for freerdp2 and freerdp3
Adding logic to check for freerdp2 first and if not the rdp module will check for freerdp3 to support the rdp module
2020-06-12 11:19:01 -04:00
van Hauser
09a247412b compiler option change 2020-06-10 10:17:40 +02:00
Henry Robalino
b0c1a9d1de
Updated version of freerdp lib supported to 3.0 2020-06-08 09:24:16 -04:00
Henry Robalino
a88198051b
add support for freerdp3"
Added support for freerdp module 3, this is the newest module from freerdp
2020-06-05 17:28:49 -04:00
van Hauser
8b603b82a2 fix makefile 2020-05-28 22:39:13 +02:00
van Hauser
1ed6909836 more buffer 2020-05-28 22:38:52 +02:00
van Hauser
e33152230b
Merge pull request #529 from kazkansouh/http-proxy-buffer-fix
http-proxy: Fix for multiline buffer
2020-05-28 22:35:08 +02:00
van Hauser
c426452772 fuck backward compatability - snprintf for the win 2020-05-21 22:43:13 +02:00
van Hauser
609201f9c4
Merge pull request #535 from TenGbps/patch-1
Update sasl.c
2020-05-21 22:37:49 +02:00
TenGbps
167a1c53e8
Update sasl.c
Some this the realm are long, if is too long is getting a #392
2020-05-21 17:46:26 +02:00
Karim Kanso
a40bfb1e54 add 404 to http-proxy as a success condition 2020-05-14 10:58:14 +01:00
Karim Kanso
99d8ef8f3c fix -Wformat-overflow= warnings in sprintf 2020-05-14 10:18:20 +01:00
Karim Kanso
dac0c18f75 fix http-proxy to handle multiline buffer data 2020-05-14 09:56:57 +01:00
van Hauser
9abb946dc1
Merge pull request #523 from maaaaz/cygwin_oracle
oracle on cygwin support
2020-04-26 16:50:51 +02:00
maaaaz
8f45980625 oracle on cygwin support 2020-04-26 09:52:11 -04:00
van Hauser
33680d9b0a
Merge pull request #522 from maaaaz/libfreerdp_libwinpr
libfreerdp2 and libwinpr2 fix in configure
2020-04-26 12:53:21 +02:00
maaaaz
e2dc1d5109 libfreerdp2 and libwinpr2 fix in configure 2020-04-26 06:44:12 -04:00
van Hauser
dea22d3e7e tiny fix 2020-04-25 18:03:24 +02:00
van Hauser
96779d6daa
Merge pull request #511 from kazkansouh/libsmbclient-eperm
SMB2: improved compatibility when null sessions fail
2020-04-08 23:21:56 +02:00
Karim Kanso
4e45f85fbb improved compatibility when null sessions fail 2020-04-08 21:32:48 +01:00
van Hauser
1ea3fc5a28
Merge pull request #509 from GitAntoinee/master
Add optional option to skip pre-request
2020-04-02 10:46:32 +02:00
GitAntoinee
8a50072e42 Fix indentation in help 2020-04-01 21:12:10 +02:00
GitAntoinee
f0424742e3 Fix indentation in help 2020-04-01 21:10:48 +02:00
Antoine
47f24cb256
Update help 2020-04-01 17:37:44 +02:00
GitAntoinee
bea3cf2bd1 Update help 2020-04-01 15:58:00 +02:00
GitAntoinee
7b053d7164 Add optional option to skip pre-request 2020-04-01 15:52:47 +02:00
van Hauser
88637abe26 fix typo 2020-04-01 12:26:28 +02:00
van Hauser
b0fc44daa2 update todo and bfg too many entries message 2020-03-10 09:53:27 +01:00
van Hauser
8426e55939
Merge pull request #500 from xambroz/patch-1
Consider the /usr/include/firebird/ path for fb
2020-03-03 20:30:37 +01:00
xambroz
4fd33e8ca2
Consider the /usr/include/firebird/ path for fb
For example on the Fedora 31 the path for the firebird include ibase.h is /usr/include/firebird/ibase.
This patch should also consider the firebird subdirectory inside the regular include directory.
2020-03-03 17:37:12 +01:00
van Hauser
90bbde1be8 clarify license 2020-02-17 11:16:51 +01:00
van Hauser
5b6fc88428 fixed crash in rtsp module 2020-02-17 10:39:17 +01:00
van Hauser
0b093e67c4 remove carriage returns in lines (pw-inspector) 2020-02-17 09:44:26 +01:00
van Hauser
720bdb3f96 code indent 2020-02-01 11:47:13 +01:00
van Hauser
531ee7734b fix for very very old compilers 2020-02-01 11:36:33 +01:00
van Hauser
60c76d0c64 BN_zero fix 2020-01-29 12:24:46 +01:00
van Hauser
13934c5b19 gcc-10 fix 2020-01-28 11:06:44 +01:00
van Hauser
0a1bdf2527
Merge pull request #491 from jer-gentoo/vnc-hydra_report-buf2
hydra-vnc: Use buf2 instead of buf in hydra_report
2020-01-27 14:44:27 +01:00
van Hauser
73318ff14f
Merge pull request #490 from jer-gentoo/modules-unused-buf
modules: Remove various unused char *buf
2020-01-27 14:44:01 +01:00
Jeroen Roovers
020137ac35 modules: Remove various unused char *buf 2020-01-26 17:09:07 +01:00
Jeroen Roovers
35cab1e127 hydra-vnc: Use buf2 instead of buf in hydra_report
A compiler warning told me that buf was used uninitialised here and it
turned out that instead of buf2, buf was being used. It makes a lot more
sense to report buf2 and that happens to fix the warning as well.
2020-01-26 17:06:47 +01:00
van Hauser
84fb3fac07
Merge pull request #489 from kazkansouh/libsmbclient
Updated xhydra to support smb2
2020-01-19 13:23:38 +01:00
Karim Kanso
c8de75bf13 Updated xhydra to support smb2 2020-01-18 19:40:14 +00:00
van Hauser
f05718824d make CFLAGS overridable 2020-01-18 11:47:36 +01:00
van Hauser
69a6b4f7d7 added changelog entry 2020-01-18 11:33:23 +01:00
van Hauser
da568a871a in the future I will learn not to push Makefile ... 2020-01-18 11:15:11 +01:00
van Hauser
a6eda41751 fixed off-by-one bug 2020-01-18 11:14:39 +01:00
van Hauser
8e3e5db7ba
Merge pull request #487 from kazkansouh/libsmbclient
SMB2/3 support
2020-01-18 11:08:05 +01:00
Karim Kanso
2423cbd5d5 smb2 module, provides linkage with libsmbclient to interface with smbv2/v3 servers.
Developed against version: 2:4.7.6+dfsg~ubuntu-0ubuntu2.1
2020-01-17 19:04:13 +00:00
van Hauser
db2a1feeb8 bump year 2020-01-07 15:09:28 +01:00
van Hauser
d0c9d7ca3f http-form parse option fix 2019-11-20 12:13:14 +01:00
owein
ccd3a99765 rolled back the http-form parameters parsing.
help for bfg's rain is in bfg's help now
2019-11-19 16:49:54 +01:00
van Hauser
b8c30ef0b0 rdp account missing permissions detection 2019-11-07 10:05:15 +01:00
van Hauser
efbc35eb50 verbose output for rdp to identify an issue 2019-11-05 09:59:36 +01:00
owein
b34655617f !!! I did not test the escapes in the miscptr !!! 2019-10-21 20:37:25 +02:00
owein
6dfd77a37d fixed http-post 2019-10-21 20:11:38 +02:00
owein
ab4aa36fd0 rolled back head_init for http-post-form, still an issue with the display 2019-10-20 23:26:44 +02:00
van Hauser
a1f3f00f86
Merge pull request #459 from e2002e/v8.8-rain
V8.8 rain
2019-10-17 12:27:26 +02:00
van Hauser
217e025475
Update bfg.h 2019-10-17 12:21:47 +02:00
van Hauser
4c0e2c2b45
Merge branch 'master' into v8.8-rain 2019-10-17 12:19:55 +02:00
e2002e
9d7ebfd3c9
false is 0 and true 1 2019-10-15 20:22:46 +02:00
e2002e
c414d9a3ab
Update bfg.c 2019-10-07 23:00:27 +02:00
owein
4b41480549 option -r and help() 2019-10-07 17:06:32 +02:00
owein
a4b4e54bd1 option -r 2019-10-07 17:04:44 +02:00
owein
b09e39f98d modified bfg 2019-10-07 17:02:43 +02:00
owein
ed9d8f1516 using hydra 8.8 files 2019-10-07 16:56:59 +02:00
owein
1658f4926f it look like github wants to drive me mad 2019-10-07 14:20:02 +02:00
David Maciejak
b911269c1a
Fix typo when only 1 password is found 2019-09-15 23:18:54 +08:00
van Hauser
ebbea58cf6 http-form parameter fix 2019-09-13 17:35:05 +02:00
van Hauser
60f4969043
Merge pull request #447 from IPv4v6/fix-typo
Fix typo in PW-Inspector
2019-09-10 23:19:29 +02:00
Stefan Pietsch
b77d49d407 Fix typo in PW-Inspector 2019-09-10 21:48:23 +02:00
David Maciejak
273334df88
Force VNC protocol version downgrade 2019-09-05 12:28:45 +08:00
David Maciejak
a06ee48826
Add entry for svn module update 2019-09-03 13:34:57 +08:00
David Maciejak
866120e4e6
Fix compilation error if missing libsvn
oops forgot the case if the lib is not installed
2019-09-02 21:18:52 +08:00
David Maciejak
e1e708d1a1 Fix compilation warning for long unsigned value printing 2019-09-02 21:05:50 +08:00
David Maciejak
b3ddd4a2d2
Fix svn_client_list3 function call deprecation
Update the module to support subversion lib from v1.5 to 1.10 and fix following warning:
hydra-svn.c:124:3: warning: \u2018svn_client_list3\u2019 is deprecated [-Wdeprecated-declarations]
   err = svn_client_list3(canonical, &revision, &revision, svn_depth_unknown, dirents, FALSE, FALSE, (svn_client_list_func2_t) print_dirdummy, NULL, ctx, pool);
2019-09-02 10:41:45 +08:00
David Maciejak
9ae7ed075a
Improve support for macOS
That's fixing the compilation issues as /lib does not exist on these systems, remove pie warnings,  and add support for libraries installed with macPorts
2019-09-01 10:15:06 +08:00
van Hauser
288d564daf
Merge pull request #443 from loonydev/master
Fix dump with folder
2019-08-30 14:31:05 +02:00
Andrii Artiushok
2a62cb30bb Fix dump with folder 2019-08-30 15:10:32 +03:00
David Maciejak
32a7a40653
Add myself back to the project 2019-08-30 16:41:32 +08:00
David Maciejak
5d25fa1d1c
Fix string matching call for system without libpcre
hydra_string_match() function is only available if libpcre is present. Compilation crashes without that patch.
2019-08-30 10:44:09 +08:00
van Hauser
150d325027 cleanup of submitted code 2019-07-29 12:04:57 +02:00
van Hauser
91ced0fa40
Merge pull request #432 from poucz/master
HTTP-GET add end condition. Simulary like in http-form
2019-07-29 11:55:43 +02:00
jopravil
98afb8e32d http-get better log 2019-07-29 09:38:37 +02:00
van Hauser
eb8fc1686c fix 2019-07-25 19:00:41 +02:00
jopravil
c639f21a72 HTTP-GET add end condition. Simulary like in http-form 2019-07-24 09:27:40 +02:00
van Hauser
a93539e872 mysql module not using a default db now 2019-07-11 11:27:07 +02:00
van Hauser
39bc8e64db more scriptkiddie annoying 2019-07-03 11:43:47 +02:00
van Hauser
71df2b3518 fcknscriptkiddies 2019-07-02 22:09:30 +02:00
van Hauser
296e5e3204 print the necessary info on found passwords with issues 2019-07-02 22:04:58 +02:00
van Hauser
74b78c5322 fix for -K 2019-06-26 10:24:22 +02:00
van Hauser
4cda4ca189 added -K no redo switch 2019-06-25 12:52:07 +02:00
David Maciejak
c2286ffb00
Remove extra comma from the json output
related to #412
2019-06-15 16:26:31 +08:00
David Maciejak
6a758105bb
Fix typo in error msg creation
Prevent typo while generating such kind of logs:
"[ERROR] 0 targets did not complete"
"1 of 1 target completed, 0 valid passwords found"
2019-06-15 16:03:16 +08:00
David Maciejak
7009b6db03 Fix json output in case of connection error to the server 2019-06-14 13:44:16 +08:00
David Maciejak
4130079209
Remove README file
Duplicated from README.md which will be used as default readme file.
2019-06-11 17:24:18 +08:00
David Maciejak
1213174e9a
Remove RDP related entry 2019-06-11 17:22:07 +08:00
David Maciejak
6e3f02b419 Add more check to detect missing header file for radmin support 2019-06-08 11:45:54 +08:00
David Maciejak
f4b48c0513 Add radmin entry and describe dependencies 2019-06-08 11:38:14 +08:00
David Maciejak
6d70d30c51
Fixed a typo in readme 2019-06-08 11:24:41 +08:00
David Maciejak
5ea9c47bb5
Fix initialization of pool struct variable 2019-06-04 13:56:48 +08:00
David Maciejak
85d51ba494
Fix memory leak
buf variable is not freed properly from the hydra_receive_line call
2019-06-04 13:53:08 +08:00
David Maciejak
2f1c1438ea
Cosmetic change
Missed that one in the previous commit.
2019-06-02 11:44:47 +08:00
David Maciejak
f2d2cd338e
Add length check for fixed-size string 2019-06-02 11:32:21 +08:00
David Maciejak
b589d658bd Merge branch 'master' of https://github.com/vanhauser-thc/thc-hydra 2019-06-02 11:23:00 +08:00
David Maciejak
87a6e9385e Cosmetic change to please code scanner 2019-06-02 11:21:54 +08:00
David Maciejak
f1e0df4080
Add length check for fixed-size string 2019-06-02 11:18:27 +08:00
David Maciejak
99205f0410
Add length check for fixed-size string
To prevent possible overflow.
2019-06-02 11:11:30 +08:00
David Maciejak
d01f473d2e Fixing distinct used types 2019-06-01 09:27:23 +08:00
David Maciejak
392bb0e3b3
Fixing open() off by one error
As reported by coverity:
off_by_one: Testing whether handle fd is strictly greater than zero is suspicious. fd leaks when it is zero
2019-05-31 18:38:10 +08:00
David Maciejak
5df0ab39c0
Fixing memory leak
lresp variable is not freed properly, also taking the chance to switch the printf calls to hydra_report function
2019-05-31 17:14:45 +08:00
David Maciejak
f6001f39e2
Initialize properly sockaddr_in structs 2019-05-30 23:43:45 +08:00
van Hauser
d24d7a8665 hydra -m help 2019-05-29 08:54:16 +02:00
van Hauser
0f70ca75d1
Merge pull request #422 from raynull/patch-1
Update hydra-redis.c
2019-05-28 12:16:24 +02:00
raynull
bd70ea79c2
Update hydra-redis.c 2019-05-28 12:52:27 +03:00
van Hauser
b9c5e7e125 better compile options 2019-05-23 14:04:14 +02:00
David Maciejak
30e5d53fce
Delete rdp header file
We don't need that header file anymore as we are relying on freerdp now.
2019-05-23 13:31:37 +08:00
van Hauser
1ad8197fb0
Merge pull request #419 from hlein/apr-limit-fix
Worked around APR_PATH_MAX errors on some Linuxes when SVN is enabled.
2019-05-19 01:06:18 +02:00
Hank Leininger
db9025bf86
Worked around APR_PATH_MAX errors on some Linuxes when SVN is enabled.
On Gentoo Linux (and possibly others?) with Subversion 1.12.0,
compilation of hydra-svn.c fails with:

In file included from /usr/include/subversion-1/svn_client.h:34,
                 from hydra-svn.c:9:
/usr/include/apr-1/apr.h:632:2: error: #error no decision has been made on APR_PATH_MAX for your platform
 #error no decision has been made on APR_PATH_MAX for your platform
  ^~~~~

This happens when PATH_MAX is not defined.

PATH_MAX is defined by /usr/include/linux/limits.h, but rather than
include'ing that directly and possibly breaking other platforms,
include sys/param.h (which will include linux/limits.h indirectly)
iff PATH_MAX is not defined and sys/param.h exists.

I based the approach on how math.h is handled.
2019-05-18 15:56:08 -06:00
van Hauser
c4667685f7 v9.1-dev init 2019-05-17 09:05:44 +02:00
van Hauser
ce3ae57645 remove outdated directory 2019-05-17 09:04:33 +02:00
van Hauser
ab467e0a3b v9.0 release 2019-05-17 08:50:01 +02:00
van Hauser
8bc67dc332
Merge pull request #418 from rmaksimov/auth-type-switching-option
fix typo and the offset value of miscptr
2019-05-16 11:46:54 +02:00
Roman Maksimov
c3c23bbd94 fix typo and the offset value of miscptr 2019-05-16 12:19:40 +03:00
van Hauser
0a0dd605ff http module a= option 2019-05-16 06:06:52 +02:00
van Hauser
c57d78c42f
Merge pull request #417 from rmaksimov/misc-fixes
Header value parsing fix and some misc changes
2019-05-15 23:12:55 +02:00
Roman Maksimov
6a57bd6877 add newline characters, fix option description in hydra-http-form.c 2019-05-15 22:58:49 +03:00
Roman Maksimov
f6723f61b1 fix parsing of header value in http(s) modules 2019-05-15 22:50:14 +03:00
van Hauser
451e3d3edd
Merge pull request #414 from rmaksimov/ntlm-auth-fix
fix NTLM authentication
2019-05-13 08:12:10 +02:00
van Hauser
a5b2f92284
Merge pull request #416 from rmaksimov/misc-fixes
Misc fixes
2019-05-12 19:50:43 +02:00
Roman Maksimov
f7f3aa1686 change the order of the comparison operands 2019-05-11 15:19:52 +03:00
Roman Maksimov
59241d6b8f change the order of the parameters as in the socket manual 2019-05-11 15:14:57 +03:00
Roman Maksimov
3424786530 fix NTLM authentication 2019-05-11 14:11:25 +03:00
David Maciejak
2bcd722941
Free the memory allocated by setupterm() 2019-04-29 09:55:57 +08:00
David Maciejak
2c7df66d42
Use specific RDP port if requested 2019-04-29 09:54:30 +08:00
van Hauser
5ca9285838
Merge pull request #410 from imhashir/master
Fixed a typo in readme
2019-04-28 12:03:57 +02:00
Hashir Baig
96641d2631 Fixed a typo in readme 2019-04-28 14:48:55 +05:00
van Hauser
a5ade64bdb
Merge pull request #409 from Galaxy-cst/master
Rebuild JSON report file in first time and append while using -R
2019-04-27 11:17:45 +02:00
Galaxy-cst
486f33cd5f Fix logical issue. It cause adding wrong output file head when restore session using JSON format 2019-04-27 10:11:02 +08:00
Galaxy-cst
5120f03645 Rebuild JSON report file in first time and append while using -R 2019-04-27 00:37:27 +08:00
van Hauser
e82e395dad Changelog update and compiler warning fix 2019-04-26 14:28:40 +02:00
David Maciejak
0fa7a484b3
Add ref to rdp module change 2019-04-25 22:16:32 +08:00
David Maciejak
c06685c308
Clean the code and handle more freerdp error code 2019-04-25 15:02:04 +08:00
van Hauser
64168bd98a
Merge pull request #405 from loianhtuan/master
replace rdesktop with freerdp for rdp module
2019-04-23 16:52:49 +02:00
Tuan
f93b799384 replace rdesktop with freerdp for rdp module 2019-04-23 18:32:22 +07:00
van Hauser
12f22f253b
Merge pull request #402 from IPv4v6/fix-typo
Fix typo in man page
2019-04-11 21:57:25 +02:00
Stefan Pietsch
caa3f0ac8f Fix typo in man page 2019-04-11 21:36:38 +02:00
van Hauser
7c81e5dd5d
Merge pull request #394 from mlsendian/master
Fix compilation error when Mongo and Memcache libraries are absent
2019-03-22 21:55:56 +01:00
Marco Slaviero
14d74ff619 Fix compilation error when Mongo and Memcache libraries are absent 2019-03-22 11:09:05 +02:00
David Maciejak
0d4bcb548f Fix conditional compilation when the proper libs are not present 2019-03-20 11:35:35 +08:00
David Maciejak
e57f97417d Merge branch 'master' of https://github.com/vanhauser-thc/thc-hydra 2019-03-20 10:45:59 +08:00
David Maciejak
012fbe6d1b Add module for mongodb 2019-03-20 10:45:42 +08:00
David Maciejak
6575bf964d Fix unauthenticated memcached server detection 2019-03-20 10:35:51 +08:00
van Hauser
95819bf458 return 255 fix 2019-03-17 09:39:03 -04:00
van Hauser
af808bc4d9 http md5-digest fix 2019-03-16 18:20:08 -04:00
David Maciejak
1ad374b6a1 Fix hydra child exit 2019-03-15 22:39:37 +08:00
David Maciejak
09b2af9c8c update README for new memcached module 2019-03-09 08:38:32 +08:00
David Maciejak
8e209b14f4 add memcached module 2019-03-09 08:30:16 +08:00
David Maciejak
4a87be9c48 Fix rtsp module potential buffer overflow 2019-03-07 08:20:15 +08:00
David Maciejak
91825f0fef Fix svn module memory leaks 2019-03-07 08:12:04 +08:00
David Maciejak
59ef84522b
Clean unsupported ftps helper message
Just for the code and message to look like unsupported pop3s, imaps, ...
2019-03-05 19:23:43 +08:00
David Maciejak
4d9740836f
Remove the extra CR
To have the perror log details on the same error line
2019-03-05 19:00:07 +08:00
David Maciejak
26e69be9a9
Missing error log carriage return 2019-03-05 18:49:37 +08:00
David Maciejak
edc01ed049
Fix compilation warning
See below full log:

hydra-http-proxy.c: In function ‘start_http_proxy’:
hydra-http-proxy.c:26:26: warning: ‘%.200s’ directive writing up to 200 bytes into a region of size 24 [-Wformat-overflow=]
     sprintf(host, "Host: %.200s", ptr + 3);
                          ^~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from hydra.h:3,
                 from hydra-mod.h:4,
                 from hydra-http-proxy.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 7 and 207 bytes into a destination of size 30
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-03-05 12:45:41 +08:00
David Maciejak
e759b3768c
Fix compilation warning
hydra-redis.c: In function ‘start_redis’:
hydra-redis.c:18:51: warning: ‘%.250s’ directive writing up to 250 bytes into a region of size between 243 and 493 [-Wformat-overflow=]
   sprintf(buffer, "*2\r\n$4\r\nAUTH\r\n$%.250s\r\n%.250s\r\n", pass_num, pass);
                                                   ^~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from hydra.h:3,
                 from hydra-mod.h:4,
                 from hydra-redis.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 20 and 520 bytes into a destination of size 510
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-03-03 23:24:09 +08:00
David Maciejak
87e410e5a1
Fix compilation warning
Fix the compilation warning below:

hydra-smtp-enum.c: In function ‘service_smtp_enum’:
hydra-mod.h:72:22: warning: statement will never be executed [-Wswitch-unreachable]
 #define hydra_report fprintf
hydra-smtp-enum.c:220:11: note: in expansion of macro ‘hydra_report’
           hydra_report(stdout, "[VERBOSE] ");
           ^~~~~~~~~~~~
2019-03-03 23:08:47 +08:00
David Maciejak
bdf0475b48
Update dependencies for Ubuntu/Debian
remove libncp, rename firebird dev libs
2019-03-03 22:54:36 +08:00
David Maciejak
d5fb1142b2
Missing carriage return when printing error 2019-03-03 22:50:22 +08:00
van Hauser
ce2fd05edf new 8.9-dev init 2019-02-26 08:43:25 -05:00
van Hauser
3a9a3c1eba v8.9.1 release 2019-02-26 08:41:10 -05:00
van Hauser
d863927a53 clarification 2019-02-26 08:38:29 -05:00
van Hauser
cb30c8442b clarification 2019-02-26 08:38:17 -05:00
van Hauser
5c1a4bbf99
Merge pull request #388 from Mattlk13/imgbot
[ImgBot] Optimize images
2019-02-24 07:55:44 -05:00
ImgBotApp
f0f546af8a
[ImgBot] Optimize images
*Total -- 614.33kb -> 589.40kb (4.06%)

/web/webfiles/img/hydra_pass.jpg -- 34.39kb -> 29.21kb (15.08%)
/web/webfiles/img/hydra_target.jpg -- 28.19kb -> 23.97kb (14.95%)
/web/webfiles/img/hydra_start.jpg -- 49.21kb -> 43.31kb (11.99%)
/xhydra.jpg -- 75.15kb -> 66.52kb (11.48%)
/web/webfiles/img/Cross.png -- 0.98kb -> 0.93kb (4.89%)
/web/xhydra.png -- 213.21kb -> 212.73kb (0.22%)
/web/webfiles/img/xhydra.png -- 213.21kb -> 212.73kb (0.22%)
2019-02-17 02:48:12 +00:00
van Hauser
ffb7b5bc8a CIDR notation now correctly identifed 2019-01-09 11:10:49 +01:00
van Hauser
3ac0595f25
Merge pull request #382 from epsilon77/master
Fix spelling error
2019-01-08 09:07:09 +01:00
Daniel Echeverry
238d9d8bb5 Fix spelling error 2019-01-07 18:45:29 -05:00
van Hauser
7565756c33 v8.9-dev init 2019-01-02 13:41:34 +01:00
136 changed files with 9532 additions and 15702 deletions

117
.clang-format Normal file
View file

@ -0,0 +1,117 @@
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 512
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
...

37
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View file

@ -0,0 +1,37 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**IMPORTANT**
This is just for reporting *BUGS* not help on how to hack, how to use hydra, command line options or how to get it compiled. Please search for help via search engines. Issues asking for this here will be closed.
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
* Ensure that you have tested the bug to be present in the current github code. You might be using an outdated version that comes with your Linux distribution!
* You must provide full command line options.
Steps to reproduce the behavior:
1. ...
2. ...
3. ...
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
Note that all messages must be in *English*, not in Chinese, Russian, etc.
**Desktop (please complete the following information):**
- OS: [e.g. Ubuntu 20.04]
- hydra version [e.g. current github state]
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**IMPORTANT**
Please note that hydra is still maintained however not actively developed. If you would like to see specific feature here it it recommended implement it yourself and send a pull request - or look for someone to do that for you :-)
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

38
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: release
on:
push:
branches: [master, main]
tags-ignore: ['**']
paths-ignore: [README, TODO, PROBLEMS]
pull_request:
paths-ignore: [README, TODO, PROBLEMS]
jobs:
docker-image:
name: Build the docker image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: gacts/github-slug@v1 # Action page: <https://github.com/gacts/github-slug>
id: slug
- uses: docker/build-push-action@v3 # Action page: <https://github.com/docker/build-push-action>
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64, linux/arm64
# ,linux/arm/v6, linux/arm/v7
tags: vanhauser/hydra:latest

1
.gitignore vendored
View file

@ -13,3 +13,4 @@ hydra-gtk/stamp-h
pw-inspector pw-inspector
pw-inspector.exe pw-inspector.exe
hydra.restore hydra.restore
*~

View file

@ -4,6 +4,9 @@ dist: trusty
os: os:
- linux - linux
- osx - osx
arch:
- amd64
- ppc64le
compiler: compiler:
- clang - clang
- gcc - gcc

View file

@ -40,6 +40,8 @@ LOCAL_SRC_FILES:= \
hydra-irc.c\ hydra-irc.c\
hydra-ldap.c\ hydra-ldap.c\
hydra-mod.c\ hydra-mod.c\
hydra-memcached.c\
hydra-mongodb.c\
hydra-mssql.c\ hydra-mssql.c\
hydra-mysql.c\ hydra-mysql.c\
hydra-ncp.c\ hydra-ncp.c\
@ -90,7 +92,8 @@ LOCAL_STATIC_LIBRARIES := \
libiconv\ libiconv\
libneon\ libneon\
libssl_static\ libssl_static\
libcrypto_static libcrypto_static\
libmemcached
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libsqlite\ libsqlite\

76
CHANGES
View file

@ -1,6 +1,82 @@
Changelog for hydra Changelog for hydra
------------------- -------------------
Release 9.5
* many modules did not support -W (all those that used a library for the
connection). All (or most?) should be fixed now.
* http-form:
- The help for http-form was wrong. the condition variable must always be
the *last* parameter, not the third
- Proxy support was not working correctly
* smb2: fix for updated libsmb2 which resulted in correct guessing attempts
not being detected
* smtp: break early if the server does not allow authentication
* rdp: detect more return codes that say a user is disabled etc.
Release 9.4
* Switched from pcre/pcre3 to pcre2 as pcre/pcre3 will be dropped from Debian
* Small fix for weird RTSP servers
* Added "2=" optional parameter to http-post-form module to tell hydra that
a "302" HTTP return code means success
* replaced wait3 with waitpid for better compatability
Release 9.3
* support Xcode compilation
* new module: cobaltstrike by ultimaiiii, thank you!
* fix for ssh to support -M or ip/range
* fix for rdp to detect empty passwords
* fix for http-form to no send empty headers
* fix for http on non-default ports when using with a proxy
* for vnc/cisco/... protocols that only check for a password, skip host
after the password is found
* fix to support IPv6 addresses in -M
* fix to test all entries in -C files, not exiting after the first found
* make disappearing targets faster to terminate on
* added "make uninstall"
Release 9.2
* fix for http-post-form optional parameters
* enable gcc 10 support for xhydra too :)
* msys support
* removed rain mode (-r) because of inefficiency
* IPv6 support for Host: header for http based modules
Release 9.1
* rdb: support for libfreerdp3 (thanks to animetauren)
* new module: smb2 which also supports smb3 (uses libsmbclient-dev) (thanks to Karim Kanso for the module!)
* oracle: added success condition (thanks to kazkansouh), compile on Cygwin (thanks to maaaaz)
* rtsp: fixed crash in MD5 auth
* svn: updated to support past and new API
* http: now supports F=/S= string matching conditions (thanks to poucz@github)
* http-proxy: buffer fix, 404 success condition (thanks to kazkansouh)
* mysql: changed not to use mysql db as a default. if the user has not access to this db auth fails ...
* sasl: buffer fix (thanks to TenGbps)
* fixed help for https modules (thanks to Jab2870)
* added -K command line switch to disable redo attempts (good for mass scanning)
* forgot to have the -m option in the hydra help output
* gcc-10 support and various cleanups by Jeroen Roovers, thanks!
* added .clang-format and formatted all code
Release 9.0
* rdp: Revamped rdp module to use FreeRDP library (thanks to loianhtuan@github for the patch!)
* Added memcached module
* Added mongodb module
* http: http module now supports a= option to select http authentication type
* JSON output does now truncate the file if exists.
* Fixed svn module memory leaks
* Fixed rtsp module potential buffer overflow
* Fixed http module DIGEST-MD5 mode
Release 8.9.1
* Clarification for rdp error message
* CIDR notation (hydra -l test -p test 192.168.0.0/24 ftp) was not detected, fixed
Release 8.8 Release 8.8
* New web page: https://github.com/vanhauser-thc/thc-hydra * New web page: https://github.com/vanhauser-thc/thc-hydra

20
CITATION.cff Normal file
View file

@ -0,0 +1,20 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- given-names: Marc
family-names: Heuse
name-particle: "van Hauser"
email: vh@thc.org
affiliation: The Hacker's Choice
title: "hydra"
version: 9.2
type: software
date-released: 2021-03-15
url: "https://github.com/vanhauser-thc/thc-hydra"
keywords:
- scanning
- passwords
- hacking
- pentesting
- securiy
license: AGPL-3.0-or-later

77
Dockerfile Normal file
View file

@ -0,0 +1,77 @@
FROM debian:bookworm-slim
ARG HYDRA_VERSION="github"
LABEL \
org.opencontainers.image.url="https://github.com/vanhauser-thc/thc-hydra" \
org.opencontainers.image.source="https://github.com/vanhauser-thc/thc-hydra" \
org.opencontainers.image.version="$HYDRA_VERSION" \
org.opencontainers.image.vendor="vanhauser-thc" \
org.opencontainers.image.title="hydra" \
org.opencontainers.image.licenses="GNU AFFERO GENERAL PUBLIC LICENSE"
COPY . /src
RUN set -x \
&& apt-get update \
&& apt-get -y install \
#libmysqlclient-dev \
default-libmysqlclient-dev \
libgpg-error-dev \
#libmemcached-dev \
#libgcrypt11-dev \
libgcrypt-dev \
#libgcrypt20-dev \
#libgtk2.0-dev \
libpcre3-dev \
#firebird-dev \
libidn11-dev \
libssh-dev \
#libsvn-dev \
libssl-dev \
#libpq-dev \
make \
curl \
gcc \
1>/dev/null \
# The next line fixes the curl "SSL certificate problem: unable to get local issuer certificate" for linux/arm
&& c_rehash
# Get hydra sources and compile
RUN cd /src \
&& make clean \
&& ./configure \
&& make \
&& make install
# Make clean
RUN apt-get purge -y make gcc \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /src
# Verify hydra installation
RUN hydra -h || error_code=$? \
&& if [ ! "${error_code}" -eq 255 ]; then echo "Wrong exit code for 'hydra help' command"; exit 1; fi \
# Unprivileged user creation
&& echo 'hydra:x:10001:10001::/tmp:/sbin/nologin' > /etc/passwd \
&& echo 'hydra:x:10001:' > /etc/group
ARG INCLUDE_SECLISTS="true"
RUN set -x \
&& if [ "${INCLUDE_SECLISTS}" = "true" ]; then \
mkdir /tmp/seclists \
&& curl -SL "https://api.github.com/repos/danielmiessler/SecLists/tarball" -o /tmp/seclists/src.tar.gz \
&& tar xzf /tmp/seclists/src.tar.gz -C /tmp/seclists \
&& mv /tmp/seclists/*SecLists*/Passwords /opt/passwords \
&& mv /tmp/seclists/*SecLists*/Usernames /opt/usernames \
&& chmod -R u+r /opt/passwords /opt/usernames \
&& rm -Rf /tmp/seclists \
&& ls -la /opt/passwords /opt/usernames \
;fi
# Use an unprivileged user
USER 10001:10001
ENTRYPOINT ["hydra"]

23
INSTALL
View file

@ -2,10 +2,27 @@ type "./configure", then "make" and finally "sudo make install"
For special modules you need to install software packages before For special modules you need to install software packages before
you run "./configure": you run "./configure":
Ubuntu/Debian: apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev firebird2.1-dev libncp-dev libncurses5-dev Ubuntu/Debian: apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev firebird-dev libncurses5-dev
Redhat/Fedora: yum install openssl-devel pcre-devel ncpfs-devel postgresql-devel libssh-devel subversion-devel libncurses-devel Redhat/Fedora: yum install openssl-devel pcre-devel ncpfs-devel postgresql-devel libssh-devel subversion-devel libncurses-devel
OpenSuSE: zypper install libopenssl-devel pcre-devel libidn-devel ncpfs-devel libssh-devel postgresql-devel subversion-devel libncurses-devel OpenSuSE: zypper install libopenssl-devel pcre-devel libidn-devel ncpfs-devel libssh-devel postgresql-devel subversion-devel libncurses-devel
For the Oracle login module, install the basic and SDK packages:
http://www.oracle.com/technetwork/database/features/instant-client/index.html For Termux/Android you need the following setup:
Install the necessary dependencies
# pkg install -y x11-repo
# pkg install -y clang make openssl openssl-tool wget openssh coreutils gtk2 gtk3
And then compiling hydra
# ./configure --prefix=$PREFIX
# make
# make install
To use xhydra, you will need to install a graphical output in termux, you can be guided from this article:
https://wiki.termux.com/wiki/Graphical_Environment
For the Oracle login module, install the basic and SDK packages:
https://www.oracle.com/database/technologies/instant-client/downloads.html

32
LICENSE
View file

@ -1,12 +1,7 @@
[see the end of the file for the special exception for linking with OpenSSL
- debian people need this]
GNU AFFERO GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007 Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -638,8 +633,8 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author> Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published
the Free Software Foundation, either version 3 of the License, or by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -648,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU Affero General Public License for more details. GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
@ -663,21 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school, You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>. <https://www.gnu.org/licenses/>.
Special Exception
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU Affero General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.

View file

@ -3,3 +3,6 @@ all:
clean: clean:
cp -f Makefile.orig Makefile cp -f Makefile.orig Makefile
uninstall:
@echo Error: you must run "./configure" first

View file

@ -1,40 +1,48 @@
# #
# Makefile for Hydra - (c) 2001-2019 by van Hauser / THC <vh@thc.org> # Makefile for Hydra - (c) 2001-2023 by van Hauser / THC <vh@thc.org>
# #
OPTS=-I. -O3 WARN_CLANG=-Wformat-nonliteral -Wstrncat-size -Wformat-security -Wsign-conversion -Wconversion -Wfloat-conversion -Wshorten-64-to-32 -Wuninitialized -Wmissing-variable-declarations -Wmissing-declarations
WARN_GCC=-Wformat=2 -Wformat-overflow=2 -Wformat-nonliteral -Wformat-truncation=2 -Wnull-dereference -Wstrict-overflow=2 -Wstringop-overflow=4 -Walloca-larger-than=4096 -Wtype-limits -Wconversion -Wtrampolines -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fno-common -Wcast-align
CFLAGS ?= -g
OPTS=-I. -O3 $(CFLAGS) -fcommon -Wno-deprecated-declarations
CPPFLAGS += -D_GNU_SOURCE
# -Wall -g -pedantic # -Wall -g -pedantic
LIBS=-lm LIBS=-lm
BINDIR = /bin
MANDIR ?= /man/man1/
DATADIR ?= /etc
DESTDIR ?= DESTDIR ?=
BINDIR = /bin
MANDIR = /man/man1/
DATADIR = /etc
PIXDIR = /share/pixmaps
APPDIR = /share/applications
SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \ SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
hydra-telnet.c hydra-cisco.c hydra-http.c hydra-ftp.c hydra-imap.c \ hydra-telnet.c hydra-cisco.c hydra-http.c hydra-ftp.c hydra-imap.c \
hydra-pop3.c hydra-smb.c hydra-icq.c hydra-cisco-enable.c hydra-ldap.c \ hydra-pop3.c hydra-smb.c hydra-icq.c hydra-cisco-enable.c hydra-ldap.c \
hydra-mysql.c hydra-mssql.c hydra-xmpp.c hydra-http-proxy-urlenum.c \ hydra-memcached.c hydra-mongodb.c hydra-mysql.c hydra-mssql.c hydra-xmpp.c \
hydra-snmp.c hydra-cvs.c hydra-smtp.c hydra-smtp-enum.c hydra-sapr3.c \ hydra-http-proxy-urlenum.c hydra-snmp.c hydra-cvs.c hydra-smtp.c \
hydra-ssh.c hydra-sshkey.c hydra-teamspeak.c hydra-postgres.c \ hydra-smtp-enum.c hydra-sapr3.c hydra-ssh.c hydra-sshkey.c hydra-teamspeak.c \
hydra-rsh.c hydra-rlogin.c hydra-oracle-listener.c hydra-svn.c \ hydra-postgres.c hydra-rsh.c hydra-rlogin.c hydra-oracle-listener.c \
hydra-pcanywhere.c hydra-sip.c hydra-oracle.c hydra-vmauthd.c \ hydra-svn.c hydra-pcanywhere.c hydra-sip.c hydra-oracle.c hydra-vmauthd.c \
hydra-asterisk.c hydra-firebird.c hydra-afp.c hydra-ncp.c hydra-rdp.c \ hydra-asterisk.c hydra-firebird.c hydra-afp.c hydra-ncp.c hydra-rdp.c \
hydra-oracle-sid.c hydra-http-proxy.c hydra-http-form.c hydra-irc.c \ hydra-oracle-sid.c hydra-http-proxy.c hydra-http-form.c hydra-irc.c \
hydra-s7-300.c hydra-redis.c hydra-adam6500.c hydra-rtsp.c \ hydra-s7-300.c hydra-redis.c hydra-adam6500.c hydra-rtsp.c \
hydra-rpcap.c hydra-radmin2.c \ hydra-rpcap.c hydra-radmin2.c hydra-cobaltstrike.c \
hydra-time.c crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c hydra-time.c crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c \
hydra-smb2.c
OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \ OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
hydra-telnet.o hydra-cisco.o hydra-http.o hydra-ftp.o hydra-imap.o \ hydra-telnet.o hydra-cisco.o hydra-http.o hydra-ftp.o hydra-imap.o \
hydra-pop3.o hydra-smb.o hydra-icq.o hydra-cisco-enable.o hydra-ldap.o \ hydra-pop3.o hydra-smb.o hydra-icq.o hydra-cisco-enable.o hydra-ldap.o \
hydra-mysql.o hydra-mssql.o hydra-xmpp.o hydra-http-proxy-urlenum.o \ hydra-memcached.o hydra-mongodb.o hydra-mysql.o hydra-mssql.o hydra-cobaltstrike.o hydra-xmpp.o \
hydra-snmp.o hydra-cvs.o hydra-smtp.o hydra-smtp-enum.o hydra-sapr3.o \ hydra-http-proxy-urlenum.o hydra-snmp.o hydra-cvs.o hydra-smtp.o \
hydra-ssh.o hydra-sshkey.o hydra-teamspeak.o hydra-postgres.o \ hydra-smtp-enum.o hydra-sapr3.o hydra-ssh.o hydra-sshkey.o hydra-teamspeak.o \
hydra-rsh.o hydra-rlogin.o hydra-oracle-listener.o hydra-svn.o \ hydra-postgres.o hydra-rsh.o hydra-rlogin.o hydra-oracle-listener.o \
hydra-pcanywhere.o hydra-sip.o hydra-oracle-sid.o hydra-oracle.o \ hydra-svn.o hydra-pcanywhere.o hydra-sip.o hydra-oracle-sid.o hydra-oracle.o \
hydra-vmauthd.o hydra-asterisk.o hydra-firebird.o hydra-afp.o \ hydra-vmauthd.o hydra-asterisk.o hydra-firebird.o hydra-afp.o \
hydra-ncp.o hydra-http-proxy.o hydra-http-form.o hydra-irc.o \ hydra-ncp.o hydra-http-proxy.o hydra-http-form.o hydra-irc.o \
hydra-redis.o hydra-rdp.o hydra-s7-300.c hydra-adam6500.o hydra-rtsp.o \ hydra-redis.o hydra-rdp.o hydra-s7-300.c hydra-adam6500.o hydra-rtsp.o \
hydra-rpcap.o hydra-radmin2.o \ hydra-rpcap.o hydra-radmin2.o \
crc32.o d3des.o bfg.o ntlm.o sasl.o hmacmd5.o hydra-mod.o hydra-time.o crc32.o d3des.o bfg.o ntlm.o sasl.o hmacmd5.o hydra-mod.o hydra-time.o \
hydra-smb2.o
BINS = hydra pw-inspector BINS = hydra pw-inspector
EXTRA_DIST = README README.arm README.palm CHANGES TODO INSTALL LICENSE \ EXTRA_DIST = README README.arm README.palm CHANGES TODO INSTALL LICENSE \
@ -60,7 +68,7 @@ pw-inspector: pw-inspector.c
$(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) -c $< $(XDEFINES) $(XIPATHS) $(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) -c $< $(XDEFINES) $(XIPATHS)
strip: all strip: all
strip $(BINS) -strip $(BINS)
-echo OK > /dev/null && test -x xhydra && strip xhydra || echo OK > /dev/null -echo OK > /dev/null && test -x xhydra && strip xhydra || echo OK > /dev/null
install: strip install: strip
@ -73,8 +81,18 @@ install: strip
-cp -f *.csv $(DESTDIR)$(PREFIX)$(DATADIR) -cp -f *.csv $(DESTDIR)$(PREFIX)$(DATADIR)
-mkdir -p $(DESTDIR)$(PREFIX)$(MANDIR) -mkdir -p $(DESTDIR)$(PREFIX)$(MANDIR)
-cp -f hydra.1 xhydra.1 pw-inspector.1 $(DESTDIR)$(PREFIX)$(MANDIR) -cp -f hydra.1 xhydra.1 pw-inspector.1 $(DESTDIR)$(PREFIX)$(MANDIR)
-mkdir -p $(DESTDIR)$(PREFIX)$(PIXDIR)
-cp -f xhydra.png $(DESTDIR)$(PREFIX)$(PIXDIR)/
-mkdir -p $(DESTDIR)$(PREFIX)$(APPDIR)
-desktop-file-install --dir $(DESTDIR)$(PREFIX)$(APPDIR) xhydra.desktop
clean: clean:
rm -rf xhydra pw-inspector hydra *.o core *.core *.stackdump *~ Makefile.in Makefile dev_rfc hydra.restore arm/*.ipk arm/ipkg/usr/bin/* hydra-gtk/src/*.o hydra-gtk/src/xhydra hydra-gtk/stamp-h hydra-gtk/config.status hydra-gtk/errors hydra-gtk/config.log hydra-gtk/src/.deps hydra-gtk/src/Makefile hydra-gtk/Makefile rm -rf xhydra pw-inspector hydra *.o core *.core *.stackdump *~ Makefile.in Makefile dev_rfc hydra.restore arm/*.ipk arm/ipkg/usr/bin/* hydra-gtk/src/*.o hydra-gtk/src/xhydra hydra-gtk/stamp-h hydra-gtk/config.status hydra-gtk/errors hydra-gtk/config.log hydra-gtk/src/.deps hydra-gtk/src/Makefile hydra-gtk/Makefile
cp -f Makefile.orig Makefile cp -f Makefile.orig Makefile
uninstall:
-rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/xhydra $(DESTDIR)$(PREFIX)$(BINDIR)/hydra $(DESTDIR)$(PREFIX)$(BINDIR)/pw-inspector $(DESTDIR)$(PREFIX)$(BINDIR)/hydra-wizard.sh $(DESTDIR)$(PREFIX)$(BINDIR)/dpl4hydra.sh
-rm -f $(DESTDIR)$(PREFIX)$(DATADIR)/dpl4hydra_full.csv $(DESTDIR)$(PREFIX)$(DATADIR)/dpl4hydra_local.csv
-rm -f $(DESTDIR)$(PREFIX)$(MANDIR)/hydra.1 $(DESTDIR)$(PREFIX)$(MANDIR)/xhydra.1 $(DESTDIR)$(PREFIX)$(MANDIR)/pw-inspector.1
-rm -f $(DESTDIR)$(PREFIX)$(PIXDIR)/xhydra.png
-rm -f $(DESTDIR)$(PREFIX)$(APPDIR)/xhydra.desktop

View file

@ -3,3 +3,6 @@ all:
clean: clean:
cp -f Makefile.orig Makefile cp -f Makefile.orig Makefile
uninstall:
@echo Error: you must run "./configure" first

View file

@ -3,5 +3,3 @@ List of known issues:
* Cygwin: more than 30 tasks (-t 31 or more) will lead to a stack smash * Cygwin: more than 30 tasks (-t 31 or more) will lead to a stack smash
* OS X: brew installed modules are not compiled correctly and will crash hydra * OS X: brew installed modules are not compiled correctly and will crash hydra
* RDP module: disabled as it does not support the current protocol. Help needed!

34
README
View file

@ -1,7 +1,7 @@
H Y D R A H Y D R A
(c) 2001-2019 by van Hauser / THC (c) 2001-2023 by van Hauser / THC
<vh@thc.org> https://github.com/vanhauser-thc/thc-hydra <vh@thc.org> https://github.com/vanhauser-thc/thc-hydra
many modules were written by David (dot) Maciejak @ gmail (dot) com many modules were written by David (dot) Maciejak @ gmail (dot) com
BFG code by Jan Dlabal <dlabaljan@gmail.com> BFG code by Jan Dlabal <dlabaljan@gmail.com>
@ -10,7 +10,17 @@
Please do not use in military or secret service organizations, Please do not use in military or secret service organizations,
or for illegal purposes. or for illegal purposes.
(This is the wish of the author and non-binding. Many people working
in these organizations do not care for laws and ethics anyways.
You are not one of the "good" ones if you ignore this.)
NOTE: no this is not meant to be a markdown doc! old school!
Hydra in the most current github state can be directly downloaded via docker:
```
docker pull vanhauser/hydra
```
INTRODUCTION INTRODUCTION
@ -24,7 +34,7 @@ access from remote to a system.
THIS TOOL IS FOR LEGAL PURPOSES ONLY! THIS TOOL IS FOR LEGAL PURPOSES ONLY!
There are already several login hacker tools available, however, none does There are already several login hacker tools available, however, none does
either support more than one protocol to attack or support parallized either support more than one protocol to attack or support parallelized
connects. connects.
It was tested to compile cleanly on Linux, Windows/Cygwin, Solaris, It was tested to compile cleanly on Linux, Windows/Cygwin, Solaris,
@ -34,8 +44,8 @@ Currently this tool supports the following protocols:
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP, Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY, HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST, HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener, HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MONGODB, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin, Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, Radmin, RDP, Rexec, Rlogin,
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5, Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth, SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
VNC and XMPP. VNC and XMPP.
@ -58,6 +68,10 @@ repository is at Github:
Use the development version at your own risk. It contains new features and Use the development version at your own risk. It contains new features and
new bugs. Things might not work! new bugs. Things might not work!
Alternatively (and easier) to can pull it as a docker container:
```
docker pull vanhauser/hydra
```
HOW TO COMPILE HOW TO COMPILE
@ -71,7 +85,7 @@ make install
``` ```
If you want the ssh module, you have to setup libssh (not libssh2!) on your If you want the ssh module, you have to setup libssh (not libssh2!) on your
system, get it from http://www.libssh.org, for ssh v1 support you also need system, get it from https://www.libssh.org, for ssh v1 support you also need
to add "-DWITH_SSH1=On" option in the cmake command line. to add "-DWITH_SSH1=On" option in the cmake command line.
IMPORTANT: If you compile on MacOS then you must do this - do not install libssh via brew! IMPORTANT: If you compile on MacOS then you must do this - do not install libssh via brew!
@ -81,7 +95,8 @@ for a few optional modules (note that some might not be available on your distri
``` ```
apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev \ apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev \
libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev \ libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev \
firebird-dev firebird-dev libmemcached-dev libgpg-error-dev \
libgcrypt11-dev libgcrypt20-dev freetds-dev
``` ```
This enables all optional modules and features with the exception of Oracle, This enables all optional modules and features with the exception of Oracle,
@ -149,7 +164,7 @@ THIRD - check if the module has optional parameters
e.g. hydra -U smtp e.g. hydra -U smtp
FOURTH - the destination port FOURTH - the destination port
this is optional! if no port is supplied the default common port for the this is optional, if no port is supplied the default common port for the
PROTOCOL is used. PROTOCOL is used.
If you specify SSL to use ("-S" option), the SSL common port is used by default. If you specify SSL to use ("-S" option), the SSL common port is used by default.
@ -166,7 +181,7 @@ All attacks are then IPv6 only!
If you want to supply your targets via a text file, you can not use the :// If you want to supply your targets via a text file, you can not use the ://
notation but use the old style and just supply the protocol (and module options): notation but use the old style and just supply the protocol (and module options):
hydra [some command line options] -M targets.txt ftp hydra [some command line options] -M targets.txt ftp
You can supply also the port for each target entry by adding ":<port>" after a You can also supply the port for each target entry by adding ":<port>" after a
target entry in the file, e.g.: target entry in the file, e.g.:
``` ```
@ -252,6 +267,7 @@ Examples:
-x 1:3:a generate passwords from length 1 to 3 with all lowercase letters -x 1:3:a generate passwords from length 1 to 3 with all lowercase letters
-x 2:5:/ generate passwords from length 2 to 5 containing only slashes -x 2:5:/ generate passwords from length 2 to 5 containing only slashes
-x 5:8:A1 generate passwords from length 5 to 8 with uppercase and numbers -x 5:8:A1 generate passwords from length 5 to 8 with uppercase and numbers
-x '3:3:aA1&~#\\ "\'<{([-|_^@)]=}>$%*?./§,;:!`' -v generates length 3 passwords with all 95 characters, and verbose.
``` ```
Example: Example:
@ -378,7 +394,7 @@ Version 1.00 example:
"These are very free form" "These are very free form"
], ],
"generator": { "generator": {
"built": "2019-03-01 14:44:22", "built": "2021-03-01 14:44:22",
"commandline": "hydra -b jsonv1 -o results.json ... ...", "commandline": "hydra -b jsonv1 -o results.json ... ...",
"jsonoutputversion": "1.00", "jsonoutputversion": "1.00",
"server": "127.0.0.1", "server": "127.0.0.1",

530
README.md
View file

@ -1,530 +0,0 @@
H Y D R A
(c) 2001-2019 by van Hauser / THC
<vh@thc.org> https://github.com/vanhauser-thc/thc-hydra
many modules were written by David (dot) Maciejak @ gmail (dot) com
BFG code by Jan Dlabal <dlabaljan@gmail.com>
Licensed under AGPLv3 (see LICENSE file)
Please do not use in military or secret service organizations,
or for illegal purposes.
INTRODUCTION
------------
Number one of the biggest security holes are passwords, as every password
security study shows.
This tool is a proof of concept code, to give researchers and security
consultants the possibility to show how easy it would be to gain unauthorized
access from remote to a system.
THIS TOOL IS FOR LEGAL PURPOSES ONLY!
There are already several login hacker tools available, however, none does
either support more than one protocol to attack or support parallized
connects.
It was tested to compile cleanly on Linux, Windows/Cygwin, Solaris,
FreeBSD/OpenBSD, QNX (Blackberry 10) and MacOS.
Currently this tool supports the following protocols:
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin,
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
VNC and XMPP.
However the module engine for new services is very easy so it won't take a
long time until even more services are supported.
Your help in writing, enhancing or fixing modules is highly appreciated!! :-)
WHERE TO GET
------------
You can always find the newest release/production version of hydra at its
project page at https://github.com/vanhauser-thc/thc-hydra/releases
If you are interested in the current development state, the public development
repository is at Github:
svn co https://github.com/vanhauser-thc/thc-hydra
or
git clone https://github.com/vanhauser-thc/thc-hydra
Use the development version at your own risk. It contains new features and
new bugs. Things might not work!
HOW TO COMPILE
--------------
To configure, compile and install hydra, just type:
```
./configure
make
make install
```
If you want the ssh module, you have to setup libssh (not libssh2!) on your
system, get it from http://www.libssh.org, for ssh v1 support you also need
to add "-DWITH_SSH1=On" option in the cmake command line.
IMPORTANT: If you compile on MacOS then you must do this - do not install libssh via brew!
If you use Ubuntu/Debian, this will install supplementary libraries needed
for a few optional modules (note that some might not be available on your distribution):
```
apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev \
libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev \
firebird-dev
```
This enables all optional modules and features with the exception of Oracle,
SAP R/3, NCP and the apple filing protocol - which you will need to download and
install from the vendor's web sites.
For all other Linux derivates and BSD based systems, use the system
software installer and look for similarly named libraries like in the
command above. In all other cases, you have to download all source libraries
and compile them manually.
SUPPORTED PLATFORMS
-------------------
- All UNIX platforms (Linux, *BSD, Solaris, etc.)
- MacOS (basically a BSD clone)
- Windows with Cygwin (both IPv4 and IPv6)
- Mobile systems based on Linux, MacOS or QNX (e.g. Android, iPhone, Blackberry 10, Zaurus, iPaq)
HOW TO USE
----------
If you just enter `hydra`, you will see a short summary of the important
options available.
Type `./hydra -h` to see all available command line options.
Note that NO login/password file is included. Generate them yourself.
A default password list is however present, use "dpl4hydra.sh" to generate
a list.
For Linux users, a GTK GUI is available, try `./xhydra`
For the command line usage, the syntax is as follows:
For attacking one target or a network, you can use the new "://" style:
hydra [some command line options] PROTOCOL://TARGET:PORT/MODULE-OPTIONS
The old mode can be used for these too, and additionally if you want to
specify your targets from a text file, you *must* use this one:
```
hydra [some command line options] [-s PORT] TARGET PROTOCOL [MODULE-OPTIONS]
```
Via the command line options you specify which logins to try, which passwords,
if SSL should be used, how many parallel tasks to use for attacking, etc.
PROTOCOL is the protocol you want to use for attacking, e.g. ftp, smtp,
http-get or many others are available
TARGET is the target you want to attack
MODULE-OPTIONS are optional values which are special per PROTOCOL module
FIRST - select your target
you have three options on how to specify the target you want to attack:
1. a single target on the command line: just put the IP or DNS address in
2. a network range on the command line: CIDR specification like "192.168.0.0/24"
3. a list of hosts in a text file: one line per entry (see below)
SECOND - select your protocol
Try to avoid telnet, as it is unreliable to detect a correct or false login attempt.
Use a port scanner to see which protocols are enabled on the target.
THIRD - check if the module has optional parameters
hydra -U PROTOCOL
e.g. hydra -U smtp
FOURTH - the destination port
this is optional! if no port is supplied the default common port for the
PROTOCOL is used.
If you specify SSL to use ("-S" option), the SSL common port is used by default.
If you use "://" notation, you must use "[" "]" brackets if you want to supply
IPv6 addresses or CIDR ("192.168.0.0/24") notations to attack:
hydra [some command line options] ftp://[192.168.0.0/24]/
hydra [some command line options] -6 smtps://[2001:db8::1]/NTLM
Note that everything hydra does is IPv4 only!
If you want to attack IPv6 addresses, you must add the "-6" command line option.
All attacks are then IPv6 only!
If you want to supply your targets via a text file, you can not use the ://
notation but use the old style and just supply the protocol (and module options):
hydra [some command line options] -M targets.txt ftp
You can supply also the port for each target entry by adding ":<port>" after a
target entry in the file, e.g.:
```
foo.bar.com
target.com:21
unusual.port.com:2121
default.used.here.com
127.0.0.1
127.0.0.1:2121
```
Note that if you want to attach IPv6 targets, you must supply the -6 option
and *must* put IPv6 addresses in brackets in the file(!) like this:
```
foo.bar.com
target.com:21
[fe80::1%eth0]
[2001::1]
[2002::2]:8080
[2a01:24a:133:0:00:123:ff:1a]
```
LOGINS AND PASSWORDS
--------------------
You have many options on how to attack with logins and passwords
With -l for login and -p for password you tell hydra that this is the only
login and/or password to try.
With -L for logins and -P for passwords you supply text files with entries.
e.g.:
```
hydra -l admin -p password ftp://localhost/
hydra -L default_logins.txt -p test ftp://localhost/
hydra -l admin -P common_passwords.txt ftp://localhost/
hydra -L logins.txt -P passwords.txt ftp://localhost/
```
Additionally, you can try passwords based on the login via the "-e" option.
The "-e" option has three parameters:
```
s - try the login as password
n - try an empty password
r - reverse the login and try it as password
```
If you want to, e.g. try "try login as password and "empty password", you
specify "-e sn" on the command line.
But there are two more modes for trying passwords than -p/-P:
You can use text file which where a login and password pair is separated by a colon,
e.g.:
```
admin:password
test:test
foo:bar
```
This is a common default account style listing, that is also generated by the
dpl4hydra.sh default account file generator supplied with hydra.
You use such a text file with the -C option - note that in this mode you
can not use -l/-L/-p/-P options (-e nsr however you can).
Example:
```
hydra -C default_accounts.txt ftp://localhost/
```
And finally, there is a bruteforce mode with the -x option (which you can not
use with -p/-P/-C):
```
-x minimum_length:maximum_length:charset
```
the charset definition is `a` for lowercase letters, `A` for uppercase letters,
`1` for numbers and for anything else you supply it is their real representation.
Examples:
```
-x 1:3:a generate passwords from length 1 to 3 with all lowercase letters
-x 2:5:/ generate passwords from length 2 to 5 containing only slashes
-x 5:8:A1 generate passwords from length 5 to 8 with uppercase and numbers
```
Example:
```
hydra -l ftp -x 3:3:a ftp://localhost/
```
SPECIAL OPTIONS FOR MODULES
---------------------------
Via the third command line parameter (TARGET SERVICE OPTIONAL) or the -m
command line option, you can pass one option to a module.
Many modules use this, a few require it!
To see the special option of a module, type:
hydra -U <module>
e.g.
./hydra -U http-post-form
The special options can be passed via the -m parameter, as 3rd command line
option or in the service://target/option format.
Examples (they are all equal):
```
./hydra -l test -p test -m PLAIN 127.0.0.1 imap
./hydra -l test -p test 127.0.0.1 imap PLAIN
./hydra -l test -p test imap://127.0.0.1/PLAIN
```
RESTORING AN ABORTED/CRASHED SESSION
------------------------------------
When hydra is aborted with Control-C, killed or crashes, it leaves a
"hydra.restore" file behind which contains all necessary information to
restore the session. This session file is written every 5 minutes.
NOTE: the hydra.restore file can NOT be copied to a different platform (e.g.
from little endian to big endian, or from Solaris to AIX)
HOW TO SCAN/CRACK OVER A PROXY
------------------------------
The environment variable HYDRA_PROXY_HTTP defines the web proxy (this works
just for the http services!).
The following syntax is valid:
```
HYDRA_PROXY_HTTP="http://123.45.67.89:8080/"
HYDRA_PROXY_HTTP="http://login:password@123.45.67.89:8080/"
HYDRA_PROXY_HTTP="proxylist.txt"
```
The last example is a text file containing up to 64 proxies (in the same
format definition as the other examples).
For all other services, use the HYDRA_PROXY variable to scan/crack.
It uses the same syntax. eg:
```
HYDRA_PROXY=[connect|socks4|socks5]://[login:password@]proxy_addr:proxy_port
```
for example:
```
HYDRA_PROXY=connect://proxy.anonymizer.com:8000
HYDRA_PROXY=socks4://auth:pw@127.0.0.1:1080
HYDRA_PROXY=socksproxylist.txt
```
ADDITIONAL HINTS
----------------
* sort your password files by likelihood and use the -u option to find
passwords much faster!
* uniq your dictionary files! this can save you a lot of time :-)
cat words.txt | sort | uniq > dictionary.txt
* if you know that the target is using a password policy (allowing users
only to choose a password with a minimum length of 6, containing a least one
letter and one number, etc. use the tool pw-inspector which comes along
with the hydra package to reduce the password list:
cat dictionary.txt | pw-inspector -m 6 -c 2 -n > passlist.txt
RESULTS OUTPUT
--------------
The results are output to stdio along with the other information. Via the -o
command line option, the results can also be written to a file. Using -b,
the format of the output can be specified. Currently, these are supported:
* `text` - plain text format
* `jsonv1` - JSON data using version 1.x of the schema (defined below).
* `json` - JSON data using the latest version of the schema, currently there
is only version 1.
If using JSON output, the results file may not be valid JSON if there are
serious errors in booting Hydra.
JSON Schema
-----------
Here is an example of the JSON output. Notes on some of the fields:
* `errormessages` - an array of zero or more strings that are normally printed
to stderr at the end of the Hydra's run. The text is very free form.
* `success` - indication if Hydra ran correctly without error (**NOT** if
passwords were detected). This parameter is either the JSON value `true`
or `false` depending on completion.
* `quantityfound` - How many username+password combinations discovered.
* `jsonoutputversion` - Version of the schema, 1.00, 1.01, 1.11, 2.00,
2.03, etc. Hydra will make second tuple of the version to always be two
digits to make it easier for downstream processors (as opposed to v1.1 vs
v1.10). The minor-level versions are additive, so 1.02 will contain more
fields than version 1.00 and will be backward compatible. Version 2.x will
break something from version 1.x output.
Version 1.00 example:
```
{
"errormessages": [
"[ERROR] Error Message of Something",
"[ERROR] Another Message",
"These are very free form"
],
"generator": {
"built": "2019-03-01 14:44:22",
"commandline": "hydra -b jsonv1 -o results.json ... ...",
"jsonoutputversion": "1.00",
"server": "127.0.0.1",
"service": "http-post-form",
"software": "Hydra",
"version": "v8.5"
},
"quantityfound": 2,
"results": [
{
"host": "127.0.0.1",
"login": "bill@example.com",
"password": "bill",
"port": 9999,
"service": "http-post-form"
},
{
"host": "127.0.0.1",
"login": "joe@example.com",
"password": "joe",
"port": 9999,
"service": "http-post-form"
}
],
"success": false
}
```
SPEED
-----
through the parallelizing feature, this password cracker tool can be very
fast, however it depends on the protocol. The fastest are generally POP3
and FTP.
Experiment with the task option (-t) to speed things up! The higher - the
faster ;-) (but too high - and it disables the service)
STATISTICS
----------
Run against a SuSE Linux 7.2 on localhost with a "-C FILE" containing
295 entries (294 tries invalid logins, 1 valid). Every test was run three
times (only for "1 task" just once), and the average noted down.
```
P A R A L L E L T A S K S
SERVICE 1 4 8 16 32 50 64 100 128
------- --------------------------------------------------------------------
telnet 23:20 5:58 2:58 1:34 1:05 0:33 0:45* 0:25* 0:55*
ftp 45:54 11:51 5:54 3:06 1:25 0:58 0:46 0:29 0:32
pop3 92:10 27:16 13:56 6:42 2:55 1:57 1:24 1:14 0:50
imap 31:05 7:41 3:51 1:58 1:01 0:39 0:32 0:25 0:21
```
(*)
Note: telnet timings can be VERY different for 64 to 128 tasks! e.g. with
128 tasks, running four times resulted in timings between 28 and 97 seconds!
The reason for this is unknown...
guesses per task (rounded up):
295 74 38 19 10 6 5 3 3
guesses possible per connect (depends on the server software and config):
telnet 4
ftp 6
pop3 1
imap 3
BUGS & FEATURES
---------------
Hydra:
Email me or David if you find bugs or if you have written a new module.
vh@thc.org (and put "antispam" in the subject line)
You should use PGP to encrypt emails to vh@thc.org :
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v3.3.3 (vh@thc.org)
mQINBFIp+7QBEADQcJctjohuYjBxq7MELAlFDvXRTeIqqh8kqHPOR018xKL09pZT
KiBWFBkU48xlR3EtV5fC1yEt8gDEULe5o0qtK1aFlYBtAWkflVNjDrs+Y2BpjITQ
FnAPHw0SOOT/jfcvmhNOZMzMU8lIubAVC4cVWoSWJbLTv6e0DRIPiYgXNT5Quh6c
vqhnI1C39pEo/W/nh3hSa16oTc5dtTLbi5kEbdzml78TnT0OASmWLI+xtYKnP+5k
Xv4xrXRMVk4L1Bv9WpCY/Jb6J8K8SJYdXPtbaIi4VjgVr5gvg9QC/d/QP2etmw3p
lJ1Ldv63x6nXsxnPq6MSOOw8+QqKc1dAgIA43k6SU4wLq9TB3x0uTKnnB8pA3ACI
zPeRN9LFkr7v1KUMeKKEdu8jUut5iKUJVu63lVYxuM5ODb6Owt3+UXgsSaQLu9nI
DZqnp/M6YTCJTJ+cJANN+uQzESI4Z2m9ITg/U/cuccN/LIDg8/eDXW3VsCqJz8Bf
lBSwMItMhs/Qwzqc1QCKfY3xcNGc4aFlJz4Bq3zSdw3mUjHYJYv1UkKntCtvvTCN
DiomxyBEKB9J7KNsOLI/CSst3MQWSG794r9ZjcfA0EWZ9u6929F2pGDZ3LiS7Jx5
n+gdBDMe0PuuonLIGXzyIuMrkfoBeW/WdnOxh+27eemcdpCb68XtQCw6UQARAQAB
tB52YW4gSGF1c2VyICgyMDEzKSA8dmhAdGhjLm9yZz6JAjkEEwECACMCGwMCHgEC
F4AFAlIp/QcGCwkIAwcCBhUKCQgLAgUWAwIBAAAKCRDI8AEqhCFiv2R9D/9qTCJJ
xCH4BUbWIUhw1zRkn9iCVSwZMmfaAhz5PdVTjeTelimMh5qwK2MNAjpR7vCCd3BH
Z2VLB2Eoz9MOgSCxcMOnCDJjtCdCOeaxiASJt8qLeRMwdMOtznM8MnKCIO8X4oo4
qH8eNj83KgpI50ERBCj/EMsgg07vSyZ9i1UXjFofFnbHRWSW9yZO16qD4F6r4SGz
dsfXARcO3QRI5lbjdGqm+g+HOPj1EFLAOxJAQOygz7ZN5fj+vPp+G/drONxNyVKp
QFtENpvqPdU9CqYh8ssazXTWeBi/TIs0q0EXkzqo7CQjfNb6tlRsg18FxnJDK/ga
V/1umTg41bQuVP9gGmycsiNI8Atr5DWqaF+O4uDmQxcxS0kX2YXQ4CSQJFi0pml5
slAGL8HaAUbV7UnQEqpayPyyTEx1i0wK5ZCHYjLBfJRZCbmHX7SbviSAzKdo5JIl
Atuk+atgW3vC3hDTrBu5qlsFCZvbxS21PJ+9zmK7ySjAEFH/NKFmx4B8kb7rPAOM
0qCTv0pD/e4ogJCxVrqQ2XcCSJWxJL31FNAMnBZpVzidudNURG2v61h3ckkSB/fP
JnkRy/yxYWrdFBYkURImxD8iFD1atj1n3EI5HBL7p/9mHxf1DVJWz7rYQk+3czvs
IhBz7xGBz4nhpCi87VDEYttghYlJanbiRfNh3okCOAQTAQIAIgUCUin7tAIbAwYL
CQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQyPABKoQhYr8OIA//cvkhoKay88yS
AjMQypach8C5CvP7eFCT11pkCt1DMAO/8Dt6Y/Ts10dPjohGdIX4PkoLTkQDwBDJ
HoLO75oqj0CYLlqDI4oHgf2uzd0Zv8f/11CQQCtut5oEK72mGNzv3GgVqg60z2KR
2vpxvGQmDwpDOPP620tf/LuRQgBpks7uazcbkAE2Br09YrUQSCBNHy8kirHW5m5C
nupMrcvuFx7mHKW1z3FuhM8ijG7oRmcBWfVoneQgIT3l2WBniXg1mKFhuUSV8Erc
XIcc11qsKshyqh0GWb2JfeXbAcTW8/4IwrCP+VfAyLO9F9khP6SnCmcNF9EVJyR6
Aw+JMNRin7PgvsqbFhpkq9N+gVBAufz3DZoMTEbsMTtW4lYG6HMWhza2+8G9XyaL
ARAWhkNVsmQQ5T6qGkI19thB6E/T6ZorTxqeopNVA7VNK3RVlKpkmUu07w5bTD6V
l3Ti6XfcSQqzt6YX2/WUE8ekEG3rSesuJ5fqjuTnIIOjBxr+pPxkzdoazlu2zJ9F
n24fHvlU20TccEWXteXj9VFzV/zbPEQbEqmE16lV+bO8U7UHqCOdE83OMrbNKszl
7LSCbFhCDtflUsyClBt/OPnlLEHgEE1j9QkqdFFy90l4HqGwKvx7lUFDnuF8LYsb
/hcP4XhqjiGcjTPYBDK254iYrpOSMZSIRgQQEQIABgUCUioGfQAKCRBDlBVOdiii
tuddAJ4zMrge4qzajScIQcXYgIWMXVenCQCfYTNQPGkHVyp3dMhJ0NR21TYoYMC5
Ag0EUin7tAEQAK5/AEIBLlA/TTgjUF3im6nu/rkWTM7/gs5H4W0a04kF4UPhaJUR
gCNlDfUnBFA0QD7Jja5LHYgLdoHXiFelPhGrbZel/Sw6sH2gkGCBtFMrVkm3u7tt
x3AZlprqqRH68Y5xTCEjGRncCAmaDgd2apgisJqXpu0dRDroFYpJFNH3vw9N2a62
0ShNakYP4ykVG3jTDC4MSl2q3BO5dzn8GYFHU0CNz6nf3gZR+48BG+zmAT77peTS
+C4Mbd6LmMmB0cuS2kYiFRwE2B69UWguLHjpXFcu9/85JJVCl2CIab7l5hpqGmgw
G/yW8HFK04Yhew7ZJOXJfUYlv1EZzR5bOsZ8Z9inC6hvFmxuCYCFnvkiEI+pOxPA
oeNOkMaT/W4W+au0ZVt3Hx+oD0pkJb5if0jrCaoAD4gpWOte6LZA8mAbKTxkHPBr
rA9/JFis5CVNI688O6eDiJqCCJjPOQA+COJI+0V+tFa6XyHPB4LxA46RxtumUZMC
v/06sDJlXMNpZbSd5Fq95YfZd4l9Vr9VrvKXfbomn+akwUymP8RDyc6Z8BzjF4Y5
02m6Ts0J0MnSYfEDqJPPZbMGB+GAgAqLs7FrZJQzOZTiOXOSIJsKMYsPIDWE8lXv
s77rs0rGvgvQfWzPsJlMIx6ryrMnAsfOkzM2GChGNX9+pABpgOdYII4bABEBAAGJ
Ah8EGAECAAkFAlIp+7QCGwwACgkQyPABKoQhYr+hrg/9Er0+HN78y6UWGFHu/KVK
d8M6ekaqjQndQXmzQaPQwsOHOvWdC+EtBoTdR3VIjAtX96uvzCRV3sb0XPB9S9eP
gRrO/t5+qTVTtjua1zzjZsMOr1SxhBgZ5+0U2aoY1vMhyIjUuwpKKNqj2uf+uj5Y
ZQbCNklghf7EVDHsYQ4goB9gsNT7rnmrzSc6UUuJOYI2jjtHp5BPMBHh2WtUVfYP
8JqDfQ+eJQr5NCFB24xMW8OxMJit3MGckUbcZlUa1wKiTb0b76fOjt0y/+9u1ykd
X+i27DAM6PniFG8BfqPq/E3iU20IZGYtaAFBuhhDWR3vGY4+r3OxdlFAJfBG9XDD
aEDTzv1XF+tEBo69GFaxXZGdk9//7qxcgiya4LL9Kltuvs82+ZzQhC09p8d3YSQN
cfaYObm4EwbINdKP7cr4anGFXvsLC9urhow/RNBLiMbRX/5qBzx2DayXtxEnDlSC
Mh7wCkNDYkSIZOrPVUFOCGxu7lloRgPxEetM5x608HRa3hDHoe5KvUBmmtavB/aR
zlGuZP1S6Y7S13ytiULSzTfUxJmyGYgNo+4ygh0i6Dudf9NLmV+i9aEIbLbd6bni
1B/y8hBSx3SVb4sQVRe3clBkfS1/mYjlldtYjzOwcd02x599KJlcChf8HnWFB7qT
zB3yrr+vYBT0uDWmxwPjiJs=
=ytEf
-----END PGP PUBLIC KEY BLOCK-----
```

5
TODO
View file

@ -1,4 +1,9 @@
./configure:
- add test for -march=native
--- this is old ---
Prio 1: Prio 1:
* add cookie support to hydra-http.c * add cookie support to hydra-http.c
* hydra-smb more than 1 connection? * hydra-smb more than 1 connection?

2
_config.yml Normal file
View file

@ -0,0 +1,2 @@
title: "thc-hydra"
theme: jekyll-theme-midnight

57
bfg.c
View file

@ -1,17 +1,17 @@
/* code original by Jan Dlabal <dlabaljan@gmail.com>, partially rewritten by vh */ /* code original by Jan Dlabal <dlabaljan@gmail.com>, partially rewritten by vh. */
#include <ctype.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h>
#include <ctype.h>
#ifdef __sun #ifdef __sun
#include <sys/int_types.h> #include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) #elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "bfg.h" #include "bfg.h"
@ -21,20 +21,26 @@ bf_option bf_options;
extern int32_t debug; extern int32_t debug;
static int32_t add_single_char(char ch, char flags, int32_t* crs_len) { static int32_t add_single_char(char ch, char flags, int32_t *crs_len) {
if ((ch >= '2' && ch <= '9') || ch == '0') { if ((ch >= '2' && ch <= '9') || ch == '0') {
if ((flags & BF_NUMS) > 0) { if ((flags & BF_NUMS) > 0) {
printf("[ERROR] character %c defined in -x although the whole number range was already defined by '1', ignored\n", ch); printf("[ERROR] character %c defined in -x although the whole number "
"range was already defined by '1', ignored\n",
ch);
return 0; return 0;
} }
//printf("[WARNING] adding character %c for -x, note that '1' will add all numbers from 0-9\n", ch); // printf("[WARNING] adding character %c for -x, note that '1' will add all
// numbers from 0-9\n", ch);
} }
if (tolower((int32_t) ch) >= 'b' && tolower((int32_t) ch) <= 'z') { if (tolower((int32_t)ch) >= 'b' && tolower((int32_t)ch) <= 'z') {
if ((ch <= 'Z' && (flags & BF_UPPER) > 0) || (ch > 'Z' && (flags & BF_UPPER) > 0)) { if ((ch <= 'Z' && (flags & BF_UPPER) > 0) || (ch > 'Z' && (flags & BF_UPPER) > 0)) {
printf("[ERROR] character %c defined in -x although the whole letter range was already defined by '%c', ignored\n", ch, ch <= 'Z' ? 'A' : 'a'); printf("[ERROR] character %c defined in -x although the whole letter "
"range was already defined by '%c', ignored\n",
ch, ch <= 'Z' ? 'A' : 'a');
return 0; return 0;
} }
//printf("[WARNING] adding character %c for -x, note that '%c' will add all %scase letters\n", ch, ch <= 'Z' ? 'A' : 'a', ch <= 'Z' ? "up" : "low"); // printf("[WARNING] adding character %c for -x, note that '%c' will add all
// %scase letters\n", ch, ch <= 'Z' ? 'A' : 'a', ch <= 'Z' ? "up" : "low");
} }
(*crs_len)++; (*crs_len)++;
if (BF_CHARSMAX - *crs_len < 1) { if (BF_CHARSMAX - *crs_len < 1) {
@ -65,7 +71,8 @@ int32_t bf_init(char *arg) {
} }
bf_options.from = atoi(arg); bf_options.from = atoi(arg);
if (bf_options.from < 1 || bf_options.from > 127) { if (bf_options.from < 1 || bf_options.from > 127) {
fprintf(stderr, "Error: minimum length must be between 1 and 127, format: -x min:max:types\n"); fprintf(stderr, "Error: minimum length must be between 1 and 127, format: "
"-x min:max:types\n");
return 1; return 1;
} }
arg = tmp + 1; arg = tmp + 1;
@ -85,7 +92,8 @@ int32_t bf_init(char *arg) {
tmp++; tmp++;
if (bf_options.from > bf_options.to) { if (bf_options.from > bf_options.to) {
fprintf(stderr, "Error: you specified a minimum length higher than the maximum length!\n"); fprintf(stderr, "Error: you specified a minimum length higher than the "
"maximum length!\n");
return 1; return 1;
} }
@ -165,23 +173,25 @@ int32_t bf_init(char *arg) {
bf_options.crs_len = crs_len; bf_options.crs_len = crs_len;
bf_options.current = bf_options.from; bf_options.current = bf_options.from;
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
if (debug) if (debug)
printf("[DEBUG] bfg INIT: from %u, to %u, len: %u, set: %s\n", bf_options.from, bf_options.to, bf_options.crs_len, bf_options.crs); printf("[DEBUG] bfg INIT: from %u, to %u, len: %u, set: %s\n", bf_options.from, bf_options.to, bf_options.crs_len, bf_options.crs);
return 0; return 0;
} }
uint64_t bf_get_pcount() { uint64_t bf_get_pcount() {
int32_t i; int32_t i;
double count = 0; double count = 0;
uint64_t foo; uint64_t foo;
for (i = bf_options.from; i <= bf_options.to; i++) for (i = bf_options.from; i <= bf_options.to; i++)
count += (pow((double) bf_options.crs_len, (double) i)); count += (pow((double)bf_options.crs_len, (double)i));
if (count >= 0xffffffff) { if (count >= 0xffffffff) {
fprintf(stderr, "\n[ERROR] definition for password bruteforce (-x) generates more than 4 billion passwords\n"); fprintf(stderr, "\n[ERROR] definition for password bruteforce (-x) "
"generates more than 4 billion passwords - this is not a bug in the program, it is just not feasible to try so many attempts. Try a calculator how long that would take. duh.\n");
exit(-1); exit(-1);
} }
@ -189,20 +199,20 @@ uint64_t bf_get_pcount() {
return foo; return foo;
} }
char *bf_next() { char *bf_next() {
int32_t i, pos = bf_options.current - 1; int32_t i, pos = bf_options.current - 1;
if (bf_options.current > bf_options.to) if (bf_options.current > bf_options.to)
return NULL; // we are done return NULL; // we are done
if ((bf_options.ptr = malloc(BF_CHARSMAX)) == NULL) { if ((bf_options.ptr = malloc(BF_CHARSMAX)) == NULL) {
fprintf(stderr, "Error: Can not allocate memory for -x data!\n"); fprintf(stderr, "Error: Can not allocate memory for -x data!\n");
return NULL; return NULL;
} }
for (i = 0; i < bf_options.current; i++) for (i = 0; i < bf_options.current; ++i)
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]]; bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
// we don't subtract the same depending on wether the length is odd or even
bf_options.ptr[bf_options.current] = 0; bf_options.ptr[bf_options.current] = 0;
if (debug) { if (debug) {
@ -212,14 +222,15 @@ char *bf_next() {
printf(", x: %s\n", bf_options.ptr); printf(", x: %s\n", bf_options.ptr);
} }
// we revert the ordering of the bruteforce to fix the first static character
while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) { while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) {
bf_options.state[pos] = 0; bf_options.state[pos] = 0;
pos--; pos--;
} }
if (pos < 0) { if (pos < 0 || pos >= bf_options.current) {
bf_options.current++; bf_options.current++;
memset((char *) bf_options.state, 0, sizeof(bf_options.state)); memset((char *)bf_options.state, 0, sizeof(bf_options.state));
} }
return bf_options.ptr; return bf_options.ptr;

14
bfg.h
View file

@ -24,7 +24,9 @@
#define BF_WEBSITE "http://houbysoft.com/bfg/" #define BF_WEBSITE "http://houbysoft.com/bfg/"
#define BF_BUFLEN 1024 #define BF_BUFLEN 1024
#define BF_CHARSMAX 256 /* how many max possibilities there are for characters, normally it's 2^8 = 256 */ #define BF_CHARSMAX \
256 /* how many max possibilities there are for characters, normally it's \
2^8 = 256 */
#define BF_LOWER 1 #define BF_LOWER 1
#define BF_UPPER 2 #define BF_UPPER 2
@ -35,11 +37,11 @@ typedef struct {
unsigned char to; unsigned char to;
unsigned char current; unsigned char current;
unsigned char state[BF_CHARSMAX]; /* which position has which character */ unsigned char state[BF_CHARSMAX]; /* which position has which character */
unsigned char pos; /* where in current string length is the position */ unsigned char pos; /* where in current string length is the position */
unsigned char crs_len; /* length of selected charset */ unsigned char crs_len; /* length of selected charset */
char *arg; /* argument received for bfg commandline option */ char *arg; /* argument received for bfg commandline option */
char *crs; /* internal representation of charset */ char *crs; /* internal representation of charset */
char *ptr; /* ptr to the last generated password */ char *ptr; /* ptr to the last generated password */
uint32_t disable_symbols; uint32_t disable_symbols;
} bf_option; } bf_option;

704
configure vendored

File diff suppressed because it is too large Load diff

138
crc32.c
View file

@ -1,99 +1,61 @@
/*- /*-
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction. * code or tables extracted from it, as desired without restriction.
* *
* First, the polynomial itself and its table of feedback terms. The * First, the polynomial itself and its table of feedback terms. The
* polynomial is * polynomial is
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
* *
* Note that we take it "backwards" and put the highest-order term in * Note that we take it "backwards" and put the highest-order term in
* the lowest-order bit. The X^32 term is "implied"; the LSB is the * the lowest-order bit. The X^32 term is "implied"; the LSB is the
* X^31 term, etc. The X^0 term (usually shown as "+1") results in * X^31 term, etc. The X^0 term (usually shown as "+1") results in
* the MSB being 1 * the MSB being 1
* *
* Note that the usual hardware shift register implementation, which * Note that the usual hardware shift register implementation, which
* is what we're using (we're merely optimizing it by doing eight-bit * is what we're using (we're merely optimizing it by doing eight-bit
* chunks at a time) shifts bits into the lowest-order term. In our * chunks at a time) shifts bits into the lowest-order term. In our
* implementation, that means shifting towards the right. Why do we * implementation, that means shifting towards the right. Why do we
* do it this way? Because the calculated CRC must be transmitted in * do it this way? Because the calculated CRC must be transmitted in
* order from highest-order term to lowest-order term. UARTs transmit * order from highest-order term to lowest-order term. UARTs transmit
* characters in order from LSB to MSB. By storing the CRC this way * characters in order from LSB to MSB. By storing the CRC this way
* we hand it to the UART in the order low-byte to high-byte; the UART * we hand it to the UART in the order low-byte to high-byte; the UART
* sends each low-bit to hight-bit; and the result is transmission bit * sends each low-bit to hight-bit; and the result is transmission bit
* by bit from highest- to lowest-order term without requiring any bit * by bit from highest- to lowest-order term without requiring any bit
* shuffling on our part. Reception works similarly * shuffling on our part. Reception works similarly
* *
* The feedback terms table consists of 256, 32-bit entries. Notes * The feedback terms table consists of 256, 32-bit entries. Notes
* *
* The table can be generated at runtime if desired; code to do so * The table can be generated at runtime if desired; code to do so
* is shown later. It might not be obvious, but the feedback * is shown later. It might not be obvious, but the feedback
* terms simply represent the results of eight shift/xor opera * terms simply represent the results of eight shift/xor opera
* tions for all combinations of data and CRC register values * tions for all combinations of data and CRC register values
* *
* The values must be right-shifted by eight bits by the "updcrc * The values must be right-shifted by eight bits by the "updcrc
* logic; the shift must be unsigned (bring in zeroes). On some * logic; the shift must be unsigned (bring in zeroes). On some
* hardware you could probably optimize the shift in assembler by * hardware you could probably optimize the shift in assembler by
* using byte-swap instructions * using byte-swap instructions
* polynomial $edb88320 * polynomial $edb88320
* *
* *
* CRC32 code derived from work by Gary S. Brown. * CRC32 code derived from work by Gary S. Brown.
*/ */
#include <sys/types.h> #include <sys/types.h>
#ifdef __sun #ifdef __sun
#include <sys/int_types.h> #include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) #elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
uint32_t crc32_tab[] = { uint32_t crc32_tab[] = {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1,
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
#ifndef HAVE_ZLIB #ifndef HAVE_ZLIB

227
d3des.c
View file

@ -37,53 +37,32 @@ static void unscrun(unsigned long *, unsigned char *);
static void desfunc(unsigned long *, unsigned long *); static void desfunc(unsigned long *, unsigned long *);
static void cookey(unsigned long *); static void cookey(unsigned long *);
static unsigned long KnL[32] = { 0L }; static unsigned long KnL[32] = {0L};
/* not needed ... /* not needed ...
static unsigned long KnR[32] = { 0L }; static unsigned long KnR[32] = { 0L };
static unsigned long Kn3[32] = { 0L }; static unsigned long Kn3[32] = { 0L };
static unsigned char Df_Key[24] = { static unsigned char Df_Key[24] = {
0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10, 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 }; 0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
*/ */
static unsigned short bytebit[8] = { static unsigned short bytebit[8] = {01, 02, 04, 010, 020, 040, 0100, 0200};
01, 02, 04, 010, 020, 040, 0100, 0200
};
static unsigned long bigbyte[24] = { static unsigned long bigbyte[24] = {0x800000L, 0x400000L, 0x200000L, 0x100000L, 0x80000L, 0x40000L, 0x20000L, 0x10000L, 0x8000L, 0x4000L, 0x2000L, 0x1000L, 0x800L, 0x400L, 0x200L, 0x100L, 0x80L, 0x40L, 0x20L, 0x10L, 0x8L, 0x4L, 0x2L, 0x1L};
0x800000L, 0x400000L, 0x200000L, 0x100000L,
0x80000L, 0x40000L, 0x20000L, 0x10000L,
0x8000L, 0x4000L, 0x2000L, 0x1000L,
0x800L, 0x400L, 0x200L, 0x100L,
0x80L, 0x40L, 0x20L, 0x10L,
0x8L, 0x4L, 0x2L, 0x1L
};
/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */ /* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
static unsigned char pc1[56] = { static unsigned char pc1[56] = {56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3};
56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35,
62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3
};
static unsigned char totrot[16] = { static unsigned char totrot[16] = {1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28};
1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
};
static unsigned char pc2[48] = { static unsigned char pc2[48] = {13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31};
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31
};
void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */ void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
unsigned char *key; unsigned char *key;
int32_t edf; int32_t edf;
{ {
register int32_t i, j, l, m, n; register int32_t i, j, l, m, n;
unsigned char pc1m[56], pcr[56]; unsigned char pc1m[56], pcr[56];
@ -126,8 +105,7 @@ void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
return; return;
} }
static void cookey(raw1) static void cookey(raw1) register unsigned long *raw1;
register unsigned long *raw1;
{ {
register unsigned long *cook, *raw0; register unsigned long *cook, *raw0;
unsigned long dough[32]; unsigned long dough[32];
@ -149,8 +127,7 @@ static void cookey(raw1)
return; return;
} }
void cpkey(into) void cpkey(into) register unsigned long *into;
register unsigned long *into;
{ {
register unsigned long *from, *endp; register unsigned long *from, *endp;
@ -160,8 +137,7 @@ void cpkey(into)
return; return;
} }
void usekey(from) void usekey(from) register unsigned long *from;
register unsigned long *from;
{ {
register unsigned long *to, *endp; register unsigned long *to, *endp;
@ -180,9 +156,8 @@ void des(unsigned char *inblock, unsigned char *outblock) {
return; return;
} }
static void scrunch(outof, into) static void scrunch(outof, into) register unsigned char *outof;
register unsigned char *outof; register unsigned long *into;
register unsigned long *into;
{ {
*into = (*outof++ & 0xffL) << 24; *into = (*outof++ & 0xffL) << 24;
*into |= (*outof++ & 0xffL) << 16; *into |= (*outof++ & 0xffL) << 16;
@ -195,9 +170,8 @@ static void scrunch(outof, into)
return; return;
} }
static void unscrun(outof, into) static void unscrun(outof, into) register unsigned long *outof;
register unsigned long *outof; register unsigned char *into;
register unsigned char *into;
{ {
*into++ = (*outof >> 24) & 0xffL; *into++ = (*outof >> 24) & 0xffL;
*into++ = (*outof >> 16) & 0xffL; *into++ = (*outof >> 16) & 0xffL;
@ -210,160 +184,31 @@ static void unscrun(outof, into)
return; return;
} }
static unsigned long SP1[64] = { static unsigned long SP1[64] = {0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L, 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L, 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L, 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L, 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L, 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L, 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L, 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L, 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L, 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L, 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L, 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L, 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L, 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L};
0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L
};
static unsigned long SP2[64] = { static unsigned long SP2[64] = {0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L, 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L, 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L, 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L, 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L, 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L, 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L, 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L, 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L, 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L, 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L, 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L, 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L, 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L};
0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L
};
static unsigned long SP3[64] = { static unsigned long SP3[64] = {0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L, 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L, 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L, 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L, 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L, 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L, 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L, 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L, 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L, 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L, 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L, 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L, 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L, 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L};
0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L
};
static unsigned long SP4[64] = { static unsigned long SP4[64] = {0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L, 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L, 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L, 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L, 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L, 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L, 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L, 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L, 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L};
0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L
};
static unsigned long SP5[64] = { static unsigned long SP5[64] = {0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L, 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L, 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L, 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L, 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L, 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L, 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L, 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L, 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L, 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L, 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L, 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L, 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L, 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L};
0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L
};
static unsigned long SP6[64] = { static unsigned long SP6[64] = {0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L, 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L, 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L, 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L, 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L, 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L, 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L, 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L, 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L, 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L, 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L, 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L, 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L, 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L};
0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L
};
static unsigned long SP7[64] = { static unsigned long SP7[64] = {0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L, 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L, 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L, 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L, 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L, 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L, 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L, 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L, 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L, 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L, 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L, 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L, 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L, 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L};
0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L
};
static unsigned long SP8[64] = { static unsigned long SP8[64] = {0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L, 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L, 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L, 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L, 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L, 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L, 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L, 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L, 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L, 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L, 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L, 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L, 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L, 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L};
0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L
};
static void desfunc(block, keys) static void desfunc(block, keys) register unsigned long *block, *keys;
register unsigned long *block, *keys;
{ {
register unsigned long fval, work, right, leftt; register unsigned long fval, work, right, leftt;
register int32_t round; register int32_t round;

10
d3des.h
View file

@ -1,9 +1,9 @@
#ifdef __sun #ifdef __sun
#include <sys/int_types.h> #include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) #elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
/* /*
@ -27,8 +27,8 @@
* (GEnie : OUTER; CIS : [71755,204]) * (GEnie : OUTER; CIS : [71755,204])
*/ */
#define EN0 0 /* MODE == encrypt */ #define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */ #define DE1 1 /* MODE == decrypt */
extern void deskey(unsigned char *, int32_t); extern void deskey(unsigned char *, int32_t);

View file

@ -2417,8 +2417,6 @@ draytek,Vigor,all,HTTP,admin,admin,Admin,,
dreambox,All models,all versions,http, telnet,root,dreambox,, dreambox,All models,all versions,http, telnet,root,dreambox,,
dreambox,All models,all versions,http,telnet,root,dreambox,gives access to a busybox allowing to control the box using basic unix commands embedded into busybox, dreambox,All models,all versions,http,telnet,root,dreambox,gives access to a busybox allowing to control the box using basic unix commands embedded into busybox,
drupal.org,Drupal,,administrator,admin,admin,,, drupal.org,Drupal,,administrator,admin,admin,,,
ducati,Diavel motorcycles,,console,,last 4 digits of the motorcycle's VIN,Start and drive the motorcycle without a key,This is the ignition password - if you have one of these bikes change the password ASAP as you may be liable for any accident damage caused by the thief!,
ducati,Diavel,,,,Last 4 digits of VIN,,,
dupont,Digital Water Proofer,,,root,par0t,,, dupont,Digital Water Proofer,,,root,par0t,,,
dynalink,RTA020,,,admin,private,,, dynalink,RTA020,,,admin,private,,,
dynalink,RTA020,,Admin,admin,private,,, dynalink,RTA020,,Admin,admin,private,,,
@ -3061,7 +3059,6 @@ hewlettpackard,Motive Chorus,,HTTP (port 5060),admin,isee,,,
hewlettpackard,Officejet,all versions,http,admin,,admin,http interface, hewlettpackard,Officejet,all versions,http,admin,,admin,http interface,
hewlettpackard,Power Manager,3,HTTP,admin,admin,Admin,, hewlettpackard,Power Manager,3,HTTP,admin,admin,Admin,,
hewlettpackard,ProcCurve MSC-5100,,,admin,admin,,, hewlettpackard,ProcCurve MSC-5100,,,admin,admin,,,
hewlettpackard,Remote Insight Board,,,Administrator,The last eight digits of the serial number,,,
hewlettpackard,StoreOnce,,,HPSupport,badg3r5,,, hewlettpackard,StoreOnce,,,HPSupport,badg3r5,,,
hewlettpackard,Vectra,,Console,,hewlpack,Admin,, hewlettpackard,Vectra,,Console,,hewlpack,Admin,,
hewlettpackard,iLo,,http,Admin,Admin,Admin,, hewlettpackard,iLo,,http,Admin,Admin,Admin,,
@ -3611,7 +3608,6 @@ iso sistemi,winwork,,Admin,,,,,
iwill,PC BIOS,,,,iwill,,, iwill,PC BIOS,,,,iwill,,,
iwill,PC BIOS,,Admin,,iwill,,, iwill,PC BIOS,,Admin,,iwill,,,
iwill,PC BIOS,,Console,,iwill,Admin,, iwill,PC BIOS,,Console,,iwill,Admin,,
jacksoncommunitycollege,My Network Services,,web,(first 7 letters of student's last name + first seven letters of first name + middle initial -- no spaces or punctuation),(First letter of first name Capitalized + First letter of last name in lowercase + day of birth {01-31} + birth year {2 digits} + last 4 digits of student ID),My Network Services access,,
jaht,adsl router,AR41/2A,HTTP,admin,epicrouter,Admin,, jaht,adsl router,AR41/2A,HTTP,admin,epicrouter,Admin,,
jamfsoftware,Casper Suite,,,jamfsoftware,jamfsw03,,, jamfsoftware,Casper Suite,,,jamfsoftware,jamfsw03,,,
janitza,UMG 508,,,Homepage Password,0th,,, janitza,UMG 508,,,Homepage Password,0th,,,
@ -3786,7 +3782,6 @@ kyocera,FS3140MFP,,Web Interface,,admin00,Administrator,,
kyocera,FS6025MFP,,system menus,Admin,Admin,Admin,, kyocera,FS6025MFP,,system menus,Admin,Admin,Admin,,
kyocera,Intermate LAN FS Pro 10/100,K82_0371,HTTP,admin,admin,Admin,, kyocera,Intermate LAN FS Pro 10/100,K82_0371,HTTP,admin,admin,Admin,,
kyocera,KM-4850W,,,admin,,,, kyocera,KM-4850W,,,admin,,,,
kyocera,KR2,,http,,read notes,,it is the last 6 characters of the mac address,
kyocera,TASKalfa 250 Ci,,,Admin,admin00,,if enable local authentification, kyocera,TASKalfa 250 Ci,,,Admin,admin00,,if enable local authentification,
kyocera,TASKalfa 250ci,,IP,,admin00,,, kyocera,TASKalfa 250ci,,IP,,admin00,,,
kyocera,TASKalfa 266ci,,Console Panel,Admin,Admin,Admin,, kyocera,TASKalfa 266ci,,Console Panel,Admin,Admin,Admin,,
@ -5188,82 +5183,42 @@ oce,tcs500, Windows XP, all models,12.3.0(1668),console, http://192.168.0.81,,
oce,tcs500,Windows XP,all models,12.3.0(1668),console,http://192.168.0.81,, oce,tcs500,Windows XP,all models,12.3.0(1668),console,http://192.168.0.81,,
ods,1094 IS Chassis,,,ods,ods,,4.x, ods,1094 IS Chassis,,,ods,ods,,4.x,
ods,1094,,,ods,ods,,, ods,1094,,,ods,ods,,,
oki,9600,,,admin,last six characters of the MAC address (letters uppercase).,,,
oki,B410,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B410dn,,http://169.254.39.211/,admin,Last 6 characters (chars uppercased) from MAC Address,admin,,
oki,B411,all ver,Http or AdminManager,root,aaaaaa,Administrator,, oki,B411,all ver,Http or AdminManager,root,aaaaaa,Administrator,,
oki,B420,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B430,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B431,all ver,Http or AdminManager,root,aaaaaa,Administrator,, oki,B431,all ver,Http or AdminManager,root,aaaaaa,Administrator,,
oki,B431dn,,http://192.168.1.xxx,root,123456,Admin,, oki,B431dn,,http://192.168.1.xxx,root,123456,Admin,,
oki,B43xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,B6100n,,,admin,OkiLAN,admin,with 61e(NIC), oki,B6100n,,,admin,OkiLAN,admin,with 61e(NIC),
oki,B6200n,,,admin,OkiLAN,admin,with 62e(NIC), oki,B6200n,,,admin,OkiLAN,admin,with 62e(NIC),
oki,B6300,,,root,last six charachter of mac address,root,,
oki,B6300n,,,admin,OkiLAN,admin,with 62e(NIC), oki,B6300n,,,admin,OkiLAN,admin,with 62e(NIC),
oki,B6500,,,root,(last 6 digits of MAC address),root,,
oki,B710,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B710,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B720,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B720,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B720N,All versions,Web interface,root,aaaaaa,Root access,, oki,B720N,All versions,Web interface,root,aaaaaa,Root access,,
oki,B730,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B730,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B8300n,,,admin,OkiLAN,admin,with 83e(NIC), oki,B8300n,,,admin,OkiLAN,admin,with 83e(NIC),
oki,B930n,,,root,(last 4 digits of MAC address),root,,
oki,C3200n,,Web Interface - Device IP,root,last 6 of MAC Address - case sensitive,,,
oki,C330,all versions etc.,http://192.168.0.1,root,aaaaaa,Admin,Administrator, oki,C330,all versions etc.,http://192.168.0.1,root,aaaaaa,Admin,Administrator,
oki,C3450,,http://192.168.1.50,admin,heslo,admin,, oki,C3450,,http://192.168.1.50,admin,heslo,admin,,
oki,C3450,,web,admin,last 6 digits of MAC code, Use uppercase letters,,
oki,C3450,,web,admin,last 6 digits of MAC code,Use uppercase letters,Administrator,
oki,C3530,,console,admin,last 6 digits of MAC address,Admin,,
oki,C380,,,admin,last 6 characters of the MAC ADRESS,,,
oki,C51xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C530dn,A1.02,http://192.168.1.51,root,aaaaaa,Admin,, oki,C530dn,A1.02,http://192.168.1.51,root,aaaaaa,Admin,,
oki,C53xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C54xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C5550 MFP,,http,,*blank*,Admin,, oki,C5550 MFP,,http,,*blank*,Admin,,
oki,C5650,,Multi,root,Last 6 characters of MAC address (uppercase),Admin,Last 6 digits are also at the end of the default printer name,
oki,C5650dn,,,,000000,menu,, oki,C5650dn,,,,000000,menu,,
oki,C5650n,,,,000000,menu,, oki,C5650n,,,,000000,menu,,
oki,C5700,,HTTP,root,the 6 last digit of the MAC adress,Admin,running with other models,
oki,C5850,,http,admin,last 6 characters of the MAC ADRESS,,,
oki,C5900,,HTTP,root,Last 6 characters (chars uppercased) from MAC Address,admin,,
oki,C6050dn,,,,000000,menu,, oki,C6050dn,,,,000000,menu,,
oki,C6050n,,,,000000,menu,, oki,C6050n,,,,000000,menu,,
oki,C610,,,admin,aaaaaa,admin,, oki,C610,,,admin,aaaaaa,admin,,
oki,C6100,,HTTP,root,Last 6 characters of MAC address (uppercase),Administrative,seems to work with a variety of oki printers.,
oki,C6150,N1.01 Network Firmware 08.51,ZeroConFig Bonjour,root,last six characters of MAC address,Basic Setup,Printer ID,Protocol
oki,C6150dn,,,,000000,menu,, oki,C6150dn,,,,000000,menu,,
oki,C6150dtn,,,,000000,menu,, oki,C6150dtn,,,,000000,menu,,
oki,C6150hdn,,,,000000,menu,, oki,C6150hdn,,,,000000,menu,,
oki,C6150n,,,,000000,menu,, oki,C6150n,,,,000000,menu,,
oki,C7000,,,admin,OkiLAN,admin,with 6200e(NIC), oki,C7000,,,admin,OkiLAN,admin,with 6200e(NIC),
oki,C7000,,,root,(last 6 digits of MAC address),admin,with 7200e(NIC) or 7300e(NIC),
oki,C710,All versions,http,root,Last 6 characters (chars uppercased) from MAC Address,Full acces to printer configuration,,
oki,C711,,Web,admin,aaaaaa,Admin access,, oki,C711,,Web,admin,aaaaaa,Admin access,,
oki,C7300,A3.14, may apply to other versions,Multi,root,Last six digits of default device name,,
oki,C7300,A3.14,may apply to other versions,Multi,root,Last six digits of default device name,Give this a try if the last six digits of the MAC don't work. I believe alpha characters would be uppercased if there were any present.,
oki,C7350,,Administrator,root,Last 6 characters (chars uppercased) from MAC Address,,,
oki,C7350,,Multi,root,Last 6 characters (chars uppercased) from MAC Address,Administrator,,
oki,C810,,http://192.168.0.1,root,Last 6 characters (chars uppercased) from MAC Address,,,
oki,C821,all version?,HTTP,root,last six charachter of mac address,Admin,,
oki,C830,all,web,root,last 6 digits of the MAC address,,,
oki,C8800,,Web or Console,root,Last six characters of MAC address,,,
oki,C9000,,,admin,OkiLAN,admin,with 6200e(NIC), oki,C9000,,,admin,OkiLAN,admin,with 6200e(NIC),
oki,C9000,,,root,(last 6 digits of MAC address),admin,with 7200e(NIC) or 7300e(NIC),
oki,C9500,,HTTP / telnet,root,Last 6 characters (chars uppercased) from MAC Address,Administration,,
oki,C9650,,,,0000,Print statistics,, oki,C9650,,,,0000,Print statistics,,
oki,C9650,,,,aaaaaa,Administration,, oki,C9650,,,,aaaaaa,Administration,,
oki,C9655,,HTTP,root,last 6 digits of MAC address,Administrator,,
oki,C9655,,printer menu,,aaaaaa,printer menubutton,, oki,C9655,,printer menu,,aaaaaa,printer menubutton,,
oki,C9800,,,root,(last 6 digits of MAC address),,,
oki,C9850,,,root,(last 6 digits of MAC address),,,
oki,CX1145,,,,123456,,, oki,CX1145,,,,123456,,,
oki,CX2032 MFP,,http,,*blank*,Admin,, oki,CX2032 MFP,,http,,*blank*,Admin,,
oki,CX2033,,Printer Menu,,,,When asked for password just press OK, oki,CX2033,,Printer Menu,,,,When asked for password just press OK,
oki,CX2633,,Web interface,admin,aaaaaa,admin,, oki,CX2633,,Web interface,admin,aaaaaa,admin,,
oki,CX2731,,Web interface,admin,aaaaaa,admin,, oki,CX2731,,Web interface,admin,aaaaaa,admin,,
oki,CX3641,,,root,(last 6 digits of MAC address),,,
oki,Color 8 +14ex,,,admin,OkiLAN,admin,with 6100e(NIC), oki,Color 8 +14ex,,,admin,OkiLAN,admin,with 6100e(NIC),
oki,ES3640,,,root,(last 6 digits of MAC address),,,
oki,ES5460 MFP,,Local configuration menu,,aaaaaa,Admin/Root i guess,, oki,ES5460 MFP,,Local configuration menu,,aaaaaa,Admin/Root i guess,,
oki,ES7120,,Web,root,aaaaaa,Admin,, oki,ES7120,,Web,root,aaaaaa,Admin,,
oki,ES7411,,web HTTP,admin,aaaaaa,Administrator,, oki,ES7411,,web HTTP,admin,aaaaaa,Administrator,,
@ -5275,7 +5230,6 @@ oki,MC160,,Op Panel,,000000,Admin,,
oki,MC160,,Web,,sysAdmin,Admin,, oki,MC160,,Web,,sysAdmin,Admin,,
oki,MC342w,,,admin,aaaaaa,admin,, oki,MC342w,,,admin,aaaaaa,admin,,
oki,MC360,,Console,admin,aaaaaa,Full acces to printer configuration,, oki,MC360,,Console,admin,aaaaaa,Full acces to printer configuration,,
oki,MC360,,HTTP,admin,Last 6 characters (chars uppercased) from MAC Address,Administration,,
oki,MC361,,Web interface,admin,aaaaaa,admin,, oki,MC361,,Web interface,admin,aaaaaa,admin,,
oki,MC560,,Printer Menu,,,,When asked for password just press OK, oki,MC560,,Printer Menu,,,,When asked for password just press OK,
oki,MC560,,Printer Menu,,,,When asked for password, oki,MC560,,Printer Menu,,,,When asked for password,
@ -5285,19 +5239,10 @@ oki,MC860,,Web interface,admin,aaaaaa,admin,,
oki,ML3xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC) oki,ML3xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC)
oki,ML491n,,http://,Admin,OkiLAN,Admin,, oki,ML491n,,http://,Admin,OkiLAN,Admin,,
oki,ML4xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC) oki,ML4xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC)
oki,ML8810,,,root,(last 6 digits of MAC address),,,
oki,N22113B,A2.00,http://192.168.1.9,,noe,Admin,, oki,N22113B,A2.00,http://192.168.1.9,,noe,Admin,,
oki,WebTools,,,Administrator,,,, oki,WebTools,,,Administrator,,,,
oki,b710,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,b710,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,c3450,All,Multi,admin,last 6 characters of the MAC ADRESS,Admin,,
oki,c3450,All,Multi,admin,last 6 characters of the MAC ADRESS,Admin,no,
oki,c511dn,B7.00,,admin,aaaaaa,Full administrator Access,the machine picks up dhcp address,manually configure static on machine directly if required or print a config page to get the dhcp address that was assigned. oki,c511dn,B7.00,,admin,aaaaaa,Full administrator Access,the machine picks up dhcp address,manually configure static on machine directly if required or print a config page to get the dhcp address that was assigned.
oki,c5300,,,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters type them as upper case",,,
oki,c5300,,Console,root,last 6 characters of the MAC ADRESS ""if it contains any alpha characters,type them as upper case"",,
oki,c5300,,Console,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters,type them as upper case",No,
oki,c5300,,Multi,root,last 6 characters of the MAC ADRESS ""if it contains any alpha characters,type them as upper case"",admin,
oki,c5300,,Multi,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters,type them as upper case",No,
oki,c5300,,admin,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters type them as upper case",,,
oki,c5750,n1.02,http://192.168.0.200,,,,, oki,c5750,n1.02,http://192.168.0.200,,,,,
oki,c810,1.0,192.100.185.78,admin,admin,admin,, oki,c810,1.0,192.100.185.78,admin,admin,admin,,
olegkhabarov,Comfy CMS,,,username,password,,, olegkhabarov,Comfy CMS,,,username,password,,,
@ -10100,7 +10045,6 @@ telus,Telephony and internet services,,,(username),telus12,User,Initial password
telus,Telephony and internet services,,,(username),telus13,User,Initial password if issued in 2013, telus,Telephony and internet services,,,(username),telus13,User,Initial password if issued in 2013,
telus,Telephony and internet services,,,(username),telus99,User,Initial password if issued in 1999, telus,Telephony and internet services,,,(username),telus99,User,Initial password if issued in 1999,
tenda,W150M,,192.168.1.1,admin,admin,Admin,, tenda,W150M,,192.168.1.1,admin,admin,Admin,,
teradyne,4TEL,VRS400,DTMF,(last 5 digits of lineman's SSN),(same as user ID),,,
terayon,,,,admin,nms,,6.29, terayon,,,,admin,nms,,6.29,
terayon,,Comcast-supplied,HTTP,,,diagnostics page,192.168.100.1/diagnostics_page.html, terayon,,Comcast-supplied,HTTP,,,diagnostics page,192.168.100.1/diagnostics_page.html,
terayon,TeraLink 1000 Controller,,,admin,password,,, terayon,TeraLink 1000 Controller,,,admin,password,,,
@ -10403,8 +10347,6 @@ unisys,ClearPath MCP,,Multi,ADMINISTRATOR,ADMINISTRATOR,Admin,,
unisys,ClearPath MCP,,Multi,HTTP,HTTP,Web Server Administration,, unisys,ClearPath MCP,,Multi,HTTP,HTTP,Web Server Administration,,
unisys,ClearPath MCP,,Multi,NAU,NAU,Privileged,Network Administration Utility, unisys,ClearPath MCP,,Multi,NAU,NAU,Privileged,Network Administration Utility,
unitedtechnologiescorporation,Interlogix truVision IP Camera,,,admin,1234,,, unitedtechnologiescorporation,Interlogix truVision IP Camera,,,admin,1234,,,
universityoftennessee,All Employee and Student Services,,,<NetID> - See Notes,See Notes,Varies with account,Username based on email - eg. if email is smith123@tennessee.edu then NetID (username) is smith123. Def. Password composed of first two letters of birth month in lower case; last two digits of birth; last four digits of UT ID Number; eg. Born Feb 1979 and UT ID Number is 123-45-6789 - default password is fe796789,
universityoftennessee,All Employee and Student Services,,,lt;NetIDgt; - See Notes,See Notes,Varies with account,Username based on email - eg. if email is smith123@tennessee.edu then NetID (username) is smith123. Def. Password composed of first two letters of birth month in lower case; last two digits of birth; last four digits of UT ID Number; eg. Born Feb 1979 and UT ID Number is 123-45-6789 - default password is fe796789,
unix,Generic,,,adm,,,, unix,Generic,,,adm,,,,
unix,Generic,,,adm,adm,,, unix,Generic,,,adm,adm,,,
unix,Generic,,,admin,admin,,, unix,Generic,,,admin,admin,,,

Can't render this file because it contains an unexpected character in line 927 and column 220.

View file

@ -2417,8 +2417,6 @@ draytek,Vigor,all,HTTP,admin,admin,Admin,,
dreambox,All models,all versions,http, telnet,root,dreambox,, dreambox,All models,all versions,http, telnet,root,dreambox,,
dreambox,All models,all versions,http,telnet,root,dreambox,gives access to a busybox allowing to control the box using basic unix commands embedded into busybox, dreambox,All models,all versions,http,telnet,root,dreambox,gives access to a busybox allowing to control the box using basic unix commands embedded into busybox,
drupal.org,Drupal,,administrator,admin,admin,,, drupal.org,Drupal,,administrator,admin,admin,,,
ducati,Diavel motorcycles,,console,,last 4 digits of the motorcycle's VIN,Start and drive the motorcycle without a key,This is the ignition password - if you have one of these bikes change the password ASAP as you may be liable for any accident damage caused by the thief!,
ducati,Diavel,,,,Last 4 digits of VIN,,,
dupont,Digital Water Proofer,,,root,par0t,,, dupont,Digital Water Proofer,,,root,par0t,,,
dynalink,RTA020,,,admin,private,,, dynalink,RTA020,,,admin,private,,,
dynalink,RTA020,,Admin,admin,private,,, dynalink,RTA020,,Admin,admin,private,,,
@ -3061,7 +3059,6 @@ hewlettpackard,Motive Chorus,,HTTP (port 5060),admin,isee,,,
hewlettpackard,Officejet,all versions,http,admin,,admin,http interface, hewlettpackard,Officejet,all versions,http,admin,,admin,http interface,
hewlettpackard,Power Manager,3,HTTP,admin,admin,Admin,, hewlettpackard,Power Manager,3,HTTP,admin,admin,Admin,,
hewlettpackard,ProcCurve MSC-5100,,,admin,admin,,, hewlettpackard,ProcCurve MSC-5100,,,admin,admin,,,
hewlettpackard,Remote Insight Board,,,Administrator,The last eight digits of the serial number,,,
hewlettpackard,StoreOnce,,,HPSupport,badg3r5,,, hewlettpackard,StoreOnce,,,HPSupport,badg3r5,,,
hewlettpackard,Vectra,,Console,,hewlpack,Admin,, hewlettpackard,Vectra,,Console,,hewlpack,Admin,,
hewlettpackard,iLo,,http,Admin,Admin,Admin,, hewlettpackard,iLo,,http,Admin,Admin,Admin,,
@ -3611,7 +3608,6 @@ iso sistemi,winwork,,Admin,,,,,
iwill,PC BIOS,,,,iwill,,, iwill,PC BIOS,,,,iwill,,,
iwill,PC BIOS,,Admin,,iwill,,, iwill,PC BIOS,,Admin,,iwill,,,
iwill,PC BIOS,,Console,,iwill,Admin,, iwill,PC BIOS,,Console,,iwill,Admin,,
jacksoncommunitycollege,My Network Services,,web,(first 7 letters of student's last name + first seven letters of first name + middle initial -- no spaces or punctuation),(First letter of first name Capitalized + First letter of last name in lowercase + day of birth {01-31} + birth year {2 digits} + last 4 digits of student ID),My Network Services access,,
jaht,adsl router,AR41/2A,HTTP,admin,epicrouter,Admin,, jaht,adsl router,AR41/2A,HTTP,admin,epicrouter,Admin,,
jamfsoftware,Casper Suite,,,jamfsoftware,jamfsw03,,, jamfsoftware,Casper Suite,,,jamfsoftware,jamfsw03,,,
janitza,UMG 508,,,Homepage Password,0th,,, janitza,UMG 508,,,Homepage Password,0th,,,
@ -3786,7 +3782,6 @@ kyocera,FS3140MFP,,Web Interface,,admin00,Administrator,,
kyocera,FS6025MFP,,system menus,Admin,Admin,Admin,, kyocera,FS6025MFP,,system menus,Admin,Admin,Admin,,
kyocera,Intermate LAN FS Pro 10/100,K82_0371,HTTP,admin,admin,Admin,, kyocera,Intermate LAN FS Pro 10/100,K82_0371,HTTP,admin,admin,Admin,,
kyocera,KM-4850W,,,admin,,,, kyocera,KM-4850W,,,admin,,,,
kyocera,KR2,,http,,read notes,,it is the last 6 characters of the mac address,
kyocera,TASKalfa 250 Ci,,,Admin,admin00,,if enable local authentification, kyocera,TASKalfa 250 Ci,,,Admin,admin00,,if enable local authentification,
kyocera,TASKalfa 250ci,,IP,,admin00,,, kyocera,TASKalfa 250ci,,IP,,admin00,,,
kyocera,TASKalfa 266ci,,Console Panel,Admin,Admin,Admin,, kyocera,TASKalfa 266ci,,Console Panel,Admin,Admin,Admin,,
@ -5188,82 +5183,42 @@ oce,tcs500, Windows XP, all models,12.3.0(1668),console, http://192.168.0.81,,
oce,tcs500,Windows XP,all models,12.3.0(1668),console,http://192.168.0.81,, oce,tcs500,Windows XP,all models,12.3.0(1668),console,http://192.168.0.81,,
ods,1094 IS Chassis,,,ods,ods,,4.x, ods,1094 IS Chassis,,,ods,ods,,4.x,
ods,1094,,,ods,ods,,, ods,1094,,,ods,ods,,,
oki,9600,,,admin,last six characters of the MAC address (letters uppercase).,,,
oki,B410,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B410dn,,http://169.254.39.211/,admin,Last 6 characters (chars uppercased) from MAC Address,admin,,
oki,B411,all ver,Http or AdminManager,root,aaaaaa,Administrator,, oki,B411,all ver,Http or AdminManager,root,aaaaaa,Administrator,,
oki,B420,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B430,,http (dhcp),admin,last six charachter of mac address (upper case),,,
oki,B431,all ver,Http or AdminManager,root,aaaaaa,Administrator,, oki,B431,all ver,Http or AdminManager,root,aaaaaa,Administrator,,
oki,B431dn,,http://192.168.1.xxx,root,123456,Admin,, oki,B431dn,,http://192.168.1.xxx,root,123456,Admin,,
oki,B43xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,B6100n,,,admin,OkiLAN,admin,with 61e(NIC), oki,B6100n,,,admin,OkiLAN,admin,with 61e(NIC),
oki,B6200n,,,admin,OkiLAN,admin,with 62e(NIC), oki,B6200n,,,admin,OkiLAN,admin,with 62e(NIC),
oki,B6300,,,root,last six charachter of mac address,root,,
oki,B6300n,,,admin,OkiLAN,admin,with 62e(NIC), oki,B6300n,,,admin,OkiLAN,admin,with 62e(NIC),
oki,B6500,,,root,(last 6 digits of MAC address),root,,
oki,B710,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B710,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B720,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B720,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B720N,All versions,Web interface,root,aaaaaa,Root access,, oki,B720N,All versions,Web interface,root,aaaaaa,Root access,,
oki,B730,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,B730,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,B8300n,,,admin,OkiLAN,admin,with 83e(NIC), oki,B8300n,,,admin,OkiLAN,admin,with 83e(NIC),
oki,B930n,,,root,(last 4 digits of MAC address),root,,
oki,C3200n,,Web Interface - Device IP,root,last 6 of MAC Address - case sensitive,,,
oki,C330,all versions etc.,http://192.168.0.1,root,aaaaaa,Admin,Administrator, oki,C330,all versions etc.,http://192.168.0.1,root,aaaaaa,Admin,Administrator,
oki,C3450,,http://192.168.1.50,admin,heslo,admin,, oki,C3450,,http://192.168.1.50,admin,heslo,admin,,
oki,C3450,,web,admin,last 6 digits of MAC code, Use uppercase letters,,
oki,C3450,,web,admin,last 6 digits of MAC code,Use uppercase letters,Administrator,
oki,C3530,,console,admin,last 6 digits of MAC address,Admin,,
oki,C380,,,admin,last 6 characters of the MAC ADRESS,,,
oki,C51xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C530dn,A1.02,http://192.168.1.51,root,aaaaaa,Admin,, oki,C530dn,A1.02,http://192.168.1.51,root,aaaaaa,Admin,,
oki,C53xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C54xx,,,root,(last 6 digits of MAC address),admin,with 8100e(NIC),
oki,C5550 MFP,,http,,*blank*,Admin,, oki,C5550 MFP,,http,,*blank*,Admin,,
oki,C5650,,Multi,root,Last 6 characters of MAC address (uppercase),Admin,Last 6 digits are also at the end of the default printer name,
oki,C5650dn,,,,000000,menu,, oki,C5650dn,,,,000000,menu,,
oki,C5650n,,,,000000,menu,, oki,C5650n,,,,000000,menu,,
oki,C5700,,HTTP,root,the 6 last digit of the MAC adress,Admin,running with other models,
oki,C5850,,http,admin,last 6 characters of the MAC ADRESS,,,
oki,C5900,,HTTP,root,Last 6 characters (chars uppercased) from MAC Address,admin,,
oki,C6050dn,,,,000000,menu,, oki,C6050dn,,,,000000,menu,,
oki,C6050n,,,,000000,menu,, oki,C6050n,,,,000000,menu,,
oki,C610,,,admin,aaaaaa,admin,, oki,C610,,,admin,aaaaaa,admin,,
oki,C6100,,HTTP,root,Last 6 characters of MAC address (uppercase),Administrative,seems to work with a variety of oki printers.,
oki,C6150,N1.01 Network Firmware 08.51,ZeroConFig Bonjour,root,last six characters of MAC address,Basic Setup,Printer ID,Protocol
oki,C6150dn,,,,000000,menu,, oki,C6150dn,,,,000000,menu,,
oki,C6150dtn,,,,000000,menu,, oki,C6150dtn,,,,000000,menu,,
oki,C6150hdn,,,,000000,menu,, oki,C6150hdn,,,,000000,menu,,
oki,C6150n,,,,000000,menu,, oki,C6150n,,,,000000,menu,,
oki,C7000,,,admin,OkiLAN,admin,with 6200e(NIC), oki,C7000,,,admin,OkiLAN,admin,with 6200e(NIC),
oki,C7000,,,root,(last 6 digits of MAC address),admin,with 7200e(NIC) or 7300e(NIC),
oki,C710,All versions,http,root,Last 6 characters (chars uppercased) from MAC Address,Full acces to printer configuration,,
oki,C711,,Web,admin,aaaaaa,Admin access,, oki,C711,,Web,admin,aaaaaa,Admin access,,
oki,C7300,A3.14, may apply to other versions,Multi,root,Last six digits of default device name,,
oki,C7300,A3.14,may apply to other versions,Multi,root,Last six digits of default device name,Give this a try if the last six digits of the MAC don't work. I believe alpha characters would be uppercased if there were any present.,
oki,C7350,,Administrator,root,Last 6 characters (chars uppercased) from MAC Address,,,
oki,C7350,,Multi,root,Last 6 characters (chars uppercased) from MAC Address,Administrator,,
oki,C810,,http://192.168.0.1,root,Last 6 characters (chars uppercased) from MAC Address,,,
oki,C821,all version?,HTTP,root,last six charachter of mac address,Admin,,
oki,C830,all,web,root,last 6 digits of the MAC address,,,
oki,C8800,,Web or Console,root,Last six characters of MAC address,,,
oki,C9000,,,admin,OkiLAN,admin,with 6200e(NIC), oki,C9000,,,admin,OkiLAN,admin,with 6200e(NIC),
oki,C9000,,,root,(last 6 digits of MAC address),admin,with 7200e(NIC) or 7300e(NIC),
oki,C9500,,HTTP / telnet,root,Last 6 characters (chars uppercased) from MAC Address,Administration,,
oki,C9650,,,,0000,Print statistics,, oki,C9650,,,,0000,Print statistics,,
oki,C9650,,,,aaaaaa,Administration,, oki,C9650,,,,aaaaaa,Administration,,
oki,C9655,,HTTP,root,last 6 digits of MAC address,Administrator,,
oki,C9655,,printer menu,,aaaaaa,printer menubutton,, oki,C9655,,printer menu,,aaaaaa,printer menubutton,,
oki,C9800,,,root,(last 6 digits of MAC address),,,
oki,C9850,,,root,(last 6 digits of MAC address),,,
oki,CX1145,,,,123456,,, oki,CX1145,,,,123456,,,
oki,CX2032 MFP,,http,,*blank*,Admin,, oki,CX2032 MFP,,http,,*blank*,Admin,,
oki,CX2033,,Printer Menu,,,,When asked for password just press OK, oki,CX2033,,Printer Menu,,,,When asked for password just press OK,
oki,CX2633,,Web interface,admin,aaaaaa,admin,, oki,CX2633,,Web interface,admin,aaaaaa,admin,,
oki,CX2731,,Web interface,admin,aaaaaa,admin,, oki,CX2731,,Web interface,admin,aaaaaa,admin,,
oki,CX3641,,,root,(last 6 digits of MAC address),,,
oki,Color 8 +14ex,,,admin,OkiLAN,admin,with 6100e(NIC), oki,Color 8 +14ex,,,admin,OkiLAN,admin,with 6100e(NIC),
oki,ES3640,,,root,(last 6 digits of MAC address),,,
oki,ES5460 MFP,,Local configuration menu,,aaaaaa,Admin/Root i guess,, oki,ES5460 MFP,,Local configuration menu,,aaaaaa,Admin/Root i guess,,
oki,ES7120,,Web,root,aaaaaa,Admin,, oki,ES7120,,Web,root,aaaaaa,Admin,,
oki,ES7411,,web HTTP,admin,aaaaaa,Administrator,, oki,ES7411,,web HTTP,admin,aaaaaa,Administrator,,
@ -5275,7 +5230,6 @@ oki,MC160,,Op Panel,,000000,Admin,,
oki,MC160,,Web,,sysAdmin,Admin,, oki,MC160,,Web,,sysAdmin,Admin,,
oki,MC342w,,,admin,aaaaaa,admin,, oki,MC342w,,,admin,aaaaaa,admin,,
oki,MC360,,Console,admin,aaaaaa,Full acces to printer configuration,, oki,MC360,,Console,admin,aaaaaa,Full acces to printer configuration,,
oki,MC360,,HTTP,admin,Last 6 characters (chars uppercased) from MAC Address,Administration,,
oki,MC361,,Web interface,admin,aaaaaa,admin,, oki,MC361,,Web interface,admin,aaaaaa,admin,,
oki,MC560,,Printer Menu,,,,When asked for password just press OK, oki,MC560,,Printer Menu,,,,When asked for password just press OK,
oki,MC560,,Printer Menu,,,,When asked for password, oki,MC560,,Printer Menu,,,,When asked for password,
@ -5285,19 +5239,10 @@ oki,MC860,,Web interface,admin,aaaaaa,admin,,
oki,ML3xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC) oki,ML3xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC)
oki,ML491n,,http://,Admin,OkiLAN,Admin,, oki,ML491n,,http://,Admin,OkiLAN,Admin,,
oki,ML4xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC) oki,ML4xx,,,admin,OkiLAN,admin,with 6010e(NIC),6020e(NIC)
oki,ML8810,,,root,(last 6 digits of MAC address),,,
oki,N22113B,A2.00,http://192.168.1.9,,noe,Admin,, oki,N22113B,A2.00,http://192.168.1.9,,noe,Admin,,
oki,WebTools,,,Administrator,,,, oki,WebTools,,,Administrator,,,,
oki,b710,all,http://192.168.1.33,root,aaaaaa,Administrator,, oki,b710,all,http://192.168.1.33,root,aaaaaa,Administrator,,
oki,c3450,All,Multi,admin,last 6 characters of the MAC ADRESS,Admin,,
oki,c3450,All,Multi,admin,last 6 characters of the MAC ADRESS,Admin,no,
oki,c511dn,B7.00,,admin,aaaaaa,Full administrator Access,the machine picks up dhcp address,manually configure static on machine directly if required or print a config page to get the dhcp address that was assigned. oki,c511dn,B7.00,,admin,aaaaaa,Full administrator Access,the machine picks up dhcp address,manually configure static on machine directly if required or print a config page to get the dhcp address that was assigned.
oki,c5300,,,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters type them as upper case",,,
oki,c5300,,Console,root,last 6 characters of the MAC ADRESS ""if it contains any alpha characters,type them as upper case"",,
oki,c5300,,Console,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters,type them as upper case",No,
oki,c5300,,Multi,root,last 6 characters of the MAC ADRESS ""if it contains any alpha characters,type them as upper case"",admin,
oki,c5300,,Multi,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters,type them as upper case",No,
oki,c5300,,admin,root,last 6 characters of the MAC ADRESS "if it contains any alpha characters type them as upper case",,,
oki,c5750,n1.02,http://192.168.0.200,,,,, oki,c5750,n1.02,http://192.168.0.200,,,,,
oki,c810,1.0,192.100.185.78,admin,admin,admin,, oki,c810,1.0,192.100.185.78,admin,admin,admin,,
olegkhabarov,Comfy CMS,,,username,password,,, olegkhabarov,Comfy CMS,,,username,password,,,
@ -10100,7 +10045,6 @@ telus,Telephony and internet services,,,(username),telus12,User,Initial password
telus,Telephony and internet services,,,(username),telus13,User,Initial password if issued in 2013, telus,Telephony and internet services,,,(username),telus13,User,Initial password if issued in 2013,
telus,Telephony and internet services,,,(username),telus99,User,Initial password if issued in 1999, telus,Telephony and internet services,,,(username),telus99,User,Initial password if issued in 1999,
tenda,W150M,,192.168.1.1,admin,admin,Admin,, tenda,W150M,,192.168.1.1,admin,admin,Admin,,
teradyne,4TEL,VRS400,DTMF,(last 5 digits of lineman's SSN),(same as user ID),,,
terayon,,,,admin,nms,,6.29, terayon,,,,admin,nms,,6.29,
terayon,,Comcast-supplied,HTTP,,,diagnostics page,192.168.100.1/diagnostics_page.html, terayon,,Comcast-supplied,HTTP,,,diagnostics page,192.168.100.1/diagnostics_page.html,
terayon,TeraLink 1000 Controller,,,admin,password,,, terayon,TeraLink 1000 Controller,,,admin,password,,,
@ -10403,8 +10347,6 @@ unisys,ClearPath MCP,,Multi,ADMINISTRATOR,ADMINISTRATOR,Admin,,
unisys,ClearPath MCP,,Multi,HTTP,HTTP,Web Server Administration,, unisys,ClearPath MCP,,Multi,HTTP,HTTP,Web Server Administration,,
unisys,ClearPath MCP,,Multi,NAU,NAU,Privileged,Network Administration Utility, unisys,ClearPath MCP,,Multi,NAU,NAU,Privileged,Network Administration Utility,
unitedtechnologiescorporation,Interlogix truVision IP Camera,,,admin,1234,,, unitedtechnologiescorporation,Interlogix truVision IP Camera,,,admin,1234,,,
universityoftennessee,All Employee and Student Services,,,<NetID> - See Notes,See Notes,Varies with account,Username based on email - eg. if email is smith123@tennessee.edu then NetID (username) is smith123. Def. Password composed of first two letters of birth month in lower case; last two digits of birth; last four digits of UT ID Number; eg. Born Feb 1979 and UT ID Number is 123-45-6789 - default password is fe796789,
universityoftennessee,All Employee and Student Services,,,lt;NetIDgt; - See Notes,See Notes,Varies with account,Username based on email - eg. if email is smith123@tennessee.edu then NetID (username) is smith123. Def. Password composed of first two letters of birth month in lower case; last two digits of birth; last four digits of UT ID Number; eg. Born Feb 1979 and UT ID Number is 123-45-6789 - default password is fe796789,
unix,Generic,,,adm,,,, unix,Generic,,,adm,,,,
unix,Generic,,,adm,adm,,, unix,Generic,,,adm,adm,,,
unix,Generic,,,admin,admin,,, unix,Generic,,,admin,admin,,,

Can't render this file because it contains an unexpected character in line 927 and column 220.

View file

@ -1,24 +1,24 @@
/* /*
Unix SMB/CIFS implementation. Unix SMB/CIFS implementation.
HMAC MD5 code for use in NTLMv2 HMAC MD5 code for use in NTLMv2
Copyright (C) Luke Kenneth Casson Leighton 1996-2000 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
Copyright (C) Andrew Tridgell 1992-2000 Copyright (C) Andrew Tridgell 1992-2000
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc. Foundation, Inc.
Free Software Foundation Free Software Foundation
51 Franklin Street, Fifth Floor 51 Franklin Street, Fifth Floor
Boston, MA 02110-1335 Boston, MA 02110-1335
@ -34,8 +34,8 @@
*/ */
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
#include <string.h>
#include "hmacmd5.h" #include "hmacmd5.h"
#include <string.h>
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
@ -43,7 +43,7 @@
the rfc 2104 version of hmac_md5 initialisation. the rfc 2104 version of hmac_md5 initialisation.
***********************************************************************/ ***********************************************************************/
void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context * ctx) { void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx) {
int32_t i; int32_t i;
unsigned char tk[16]; unsigned char tk[16];
@ -52,7 +52,7 @@ void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Con
MD5_CTX tctx; MD5_CTX tctx;
MD5_Init(&tctx); MD5_Init(&tctx);
MD5_Update(&tctx, (void *) key, key_len); MD5_Update(&tctx, (void *)key, key_len);
MD5_Final(tk, &tctx); MD5_Final(tk, &tctx);
key = tk; key = tk;
@ -79,7 +79,7 @@ void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Con
the microsoft version of hmac_md5 initialisation. the microsoft version of hmac_md5 initialisation.
***********************************************************************/ ***********************************************************************/
void hmac_md5_init_limK_to_64(const unsigned char *key, int32_t key_len, HMACMD5Context * ctx) { void hmac_md5_init_limK_to_64(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx) {
int32_t i; int32_t i;
/* if key is longer than 64 bytes truncate it */ /* if key is longer than 64 bytes truncate it */
@ -107,15 +107,12 @@ void hmac_md5_init_limK_to_64(const unsigned char *key, int32_t key_len, HMACMD5
update hmac_md5 "inner" buffer update hmac_md5 "inner" buffer
***********************************************************************/ ***********************************************************************/
void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context * ctx) { void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context *ctx) { MD5_Update(&ctx->ctx, (void *)text, text_len); /* then text of datagram */ }
MD5_Update(&ctx->ctx, (void *) text, text_len); /* then text of datagram */
}
/*********************************************************************** /***********************************************************************
finish off hmac_md5 "inner" buffer and generate outer one. finish off hmac_md5 "inner" buffer and generate outer one.
***********************************************************************/ ***********************************************************************/
void hmac_md5_final(unsigned char *digest, HMACMD5Context * ctx) void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx) {
{
MD5_CTX ctx_o; MD5_CTX ctx_o;
MD5_Final(digest, &ctx->ctx); MD5_Final(digest, &ctx->ctx);

View file

@ -1,19 +1,19 @@
/* /*
Unix SMB/CIFS implementation. Unix SMB/CIFS implementation.
Interface header: Scheduler service Interface header: Scheduler service
Copyright (C) Luke Kenneth Casson Leighton 1996-1999 Copyright (C) Luke Kenneth Casson Leighton 1996-1999
Copyright (C) Andrew Tridgell 1992-1999 Copyright (C) Andrew Tridgell 1992-1999
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc. Foundation, Inc.
@ -30,28 +30,25 @@
*/ */
#ifdef __sun #ifdef __sun
#include <sys/int_types.h> #include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) #elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <openssl/md5.h> #include <openssl/md5.h>
#ifndef _HMAC_MD5_H #ifndef _HMAC_MD5_H
typedef struct { typedef struct {
MD5_CTX ctx; MD5_CTX ctx;
unsigned char k_ipad[65]; unsigned char k_ipad[65];
unsigned char k_opad[65]; unsigned char k_opad[65];
} HMACMD5Context; } HMACMD5Context;
#endif /* _HMAC_MD5_H */ #endif /* _HMAC_MD5_H */
void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx); void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx);
void hmac_md5_init_limK_to_64(const unsigned char* key, int32_t key_len,HMACMD5Context *ctx); void hmac_md5_init_limK_to_64(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx);
void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context *ctx); void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context *ctx);
void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx); void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx);
void hmac_md5( unsigned char key[16], unsigned char *data, int32_t data_len, unsigned char *digest); void hmac_md5(unsigned char key[16], unsigned char *data, int32_t data_len, unsigned char *digest);

View file

@ -6,57 +6,15 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
unsigned char adam6500_req1[] = { unsigned char adam6500_req1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x10, 0x27, 0x0f, 0x00, 0x08, 0x10, 0x24, 0x30, 0x31, 0x50, 0x57, 0x30, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0d, 0x00};
0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x10, unsigned char adam6500_resp1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x27, 0x0f, 0x00, 0x08};
0x27, 0x0f, 0x00, 0x08, 0x10, 0x24, 0x30, 0x31, unsigned char adam6500_req2[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x27, 0x0f, 0x00, 0x7d};
0x50, 0x57, 0x30, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, unsigned char adam6500_resp2[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x01, 0x03, 0xfa, 0x3f, 0x30, 0x31, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1f, 0x1f, 0x1f, 0x0d, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char adam6500_resp1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10,
0x27, 0x0f, 0x00, 0x08
};
unsigned char adam6500_req2[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03,
0x27, 0x0f, 0x00, 0x7d
};
unsigned char adam6500_resp2[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x01, 0x03,
0xfa, 0x3f, 0x30, 0x31, 0x0d, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};
int32_t start_adam6500(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_adam6500(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *pass; char *pass;
unsigned char buffer[300]; unsigned char buffer[300];
@ -66,13 +24,13 @@ int32_t start_adam6500(int32_t s, char *ip, int32_t port, unsigned char options,
pass = empty; pass = empty;
memcpy(buffer, adam6500_req1, sizeof(adam6500_req1)); memcpy(buffer, adam6500_req1, sizeof(adam6500_req1));
for (i = 0; i < 8 && i < strlen(pass); i++) for (i = 0; i < 8 && i < strlen(pass); i++)
buffer[19 + i] = pass[i] ^ 0x3f; buffer[19 + i] = pass[i] ^ 0x3f;
if (hydra_send(s, buffer, sizeof(adam6500_req1), 0) < 0) if (hydra_send(s, buffer, sizeof(adam6500_req1), 0) < 0)
return 1; return 1;
if (recv(s, buffer, sizeof(buffer), 0) == 12 && memcmp(buffer, adam6500_resp1, sizeof(adam6500_resp1)) == 0) { if (recv(s, buffer, sizeof(buffer), 0) == 12 && memcmp(buffer, adam6500_resp1, sizeof(adam6500_resp1)) == 0) {
if (hydra_send(s, adam6500_req2, sizeof(adam6500_req2), 0) < 0) if (hydra_send(s, adam6500_req2, sizeof(adam6500_req2), 0) < 0)
return 1; return 1;
@ -90,7 +48,7 @@ int32_t start_adam6500(int32_t s, char *ip, int32_t port, unsigned char options,
return 1; return 1;
} }
void service_adam6500(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_adam6500(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ADAM6500, mysslport = PORT_ADAM6500_SSL; int32_t myport = PORT_ADAM6500, mysslport = PORT_ADAM6500_SSL;
@ -100,34 +58,34 @@ void service_adam6500(char *ip, int32_t sp, unsigned char options, char *miscptr
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_adam6500(sock, ip, port, options, miscptr, fp); next_run = start_adam6500(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -145,13 +103,13 @@ void service_adam6500(char *ip, int32_t sp, unsigned char options, char *miscptr
} }
} }
int32_t service_adam6500_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_adam6500_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -1,6 +1,6 @@
/* /*
* Apple Filing Protocol Support - by David Maciejak @ GMAIL dot com * Apple Filing Protocol Support - by David Maciejak @ GMAIL dot com
* *
* tested with afpfs-ng 0.8.1 * tested with afpfs-ng 0.8.1
* AFPFS-NG: http://alexthepuffin.googlepages.com/home * AFPFS-NG: http://alexthepuffin.googlepages.com/home
* *
@ -9,33 +9,31 @@
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBAFP #ifndef LIBAFP
void dummy_afp() { void dummy_afp() { printf("\n"); }
printf("\n");
}
#else #else
#define FREE(x) \ #define FREE(x) \
if (x != NULL) { \ if (x != NULL) { \
free(x); \ free(x); \
x = NULL; \ x = NULL; \
} }
#include <stdio.h>
#include <afpfs-ng/afp.h> #include <afpfs-ng/afp.h>
#include <afpfs-ng/libafpclient.h> #include <afpfs-ng/libafpclient.h>
#include <stdio.h>
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
void stdout_fct(void *priv, enum loglevels loglevel, int32_t logtype, const char *message) { void stdout_fct(void *priv, enum loglevels loglevel, int32_t logtype, const char *message) {
//fprintf(stderr, "[ERROR] Caught unknown error %s\n", message); // fprintf(stderr, "[ERROR] Caught unknown error %s\n", message);
} }
static struct libafpclient afpclient = { static struct libafpclient afpclient = {
.unmount_volume = NULL, .unmount_volume = NULL,
.log_for_client = stdout_fct, .log_for_client = stdout_fct,
.forced_ending_hook = NULL, .forced_ending_hook = NULL,
.scan_extra_fds = NULL, .scan_extra_fds = NULL,
.loop_started = NULL, .loop_started = NULL,
}; };
static int32_t server_subconnect(struct afp_url url) { static int32_t server_subconnect(struct afp_url url) {
@ -43,18 +41,19 @@ static int32_t server_subconnect(struct afp_url url) {
struct afp_server *server = NULL; struct afp_server *server = NULL;
conn_req = malloc(sizeof(struct afp_connection_request)); conn_req = malloc(sizeof(struct afp_connection_request));
// server = malloc(sizeof(struct afp_server)); // server = malloc(sizeof(struct afp_server));
memset(conn_req, 0, sizeof(struct afp_connection_request)); memset(conn_req, 0, sizeof(struct afp_connection_request));
conn_req->url = url; conn_req->url = url;
conn_req->url.requested_version = 31; conn_req->url.requested_version = 31;
//fprintf(stderr, "AFP connection - username: %s password: %s server: %s\n", url.username, url.password, url.servername); // fprintf(stderr, "AFP connection - username: %s password: %s server: %s\n",
// url.username, url.password, url.servername);
if (strlen(url.uamname) > 0) { if (strlen(url.uamname) > 0) {
if ((conn_req->uam_mask = find_uam_by_name(url.uamname)) == 0) { if ((conn_req->uam_mask = find_uam_by_name(url.uamname)) == 0) {
fprintf(stderr, "[ERROR] Unknown UAM: %s", url.uamname); fprintf(stderr, "[ERROR] Unknown UAM: %s\n", url.uamname);
FREE(conn_req); FREE(conn_req);
FREE(server); FREE(server);
return -1; return -1;
@ -63,13 +62,14 @@ static int32_t server_subconnect(struct afp_url url) {
conn_req->uam_mask = default_uams_mask(); conn_req->uam_mask = default_uams_mask();
} }
//fprintf(stderr, "Initiating connection attempt.\n"); // fprintf(stderr, "Initiating connection attempt.\n");
if ((server = afp_server_full_connect(NULL, conn_req)) == NULL) { if ((server = afp_server_full_connect(NULL, conn_req)) == NULL) {
FREE(conn_req); FREE(conn_req);
// FREE(server); // FREE(server);
return -1; return -1;
} }
//fprintf(stderr, "Connected to server: %s via UAM: %s\n", server->server_name_printable, uam_bitmap_to_string(server->using_uam)); // fprintf(stderr, "Connected to server: %s via UAM: %s\n",
// server->server_name_printable, uam_bitmap_to_string(server->using_uam));
FREE(conn_req); FREE(conn_req);
FREE(server); FREE(server);
@ -77,7 +77,7 @@ static int32_t server_subconnect(struct afp_url url) {
return 0; return 0;
} }
int32_t start_afp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_afp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, mlogin[AFP_MAX_USERNAME_LEN], mpass[AFP_MAX_PASSWORD_LEN]; char *login, *pass, mlogin[AFP_MAX_USERNAME_LEN], mpass[AFP_MAX_PASSWORD_LEN];
struct afp_url tmpurl; struct afp_url tmpurl;
@ -88,7 +88,6 @@ int32_t start_afp(int32_t s, char *ip, int32_t port, unsigned char options, char
init_uams(); init_uams();
afp_default_url(&tmpurl); afp_default_url(&tmpurl);
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
@ -110,7 +109,6 @@ int32_t start_afp(int32_t s, char *ip, int32_t port, unsigned char options, char
return 3; return 3;
return 2; return 2;
} else { } else {
hydra_completed_pair(); hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 2; return 2;
@ -118,7 +116,7 @@ int32_t start_afp(int32_t s, char *ip, int32_t port, unsigned char options, char
return 1; return 1;
} }
void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_AFP; int32_t myport = PORT_AFP;
@ -127,9 +125,8 @@ void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -139,7 +136,8 @@ void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
port = myport; port = myport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -149,7 +147,7 @@ void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
case 2: case 2:
/* /*
* Here we start the password cracking process * Here we start the password cracking process
*/ */
next_run = start_afp(sock, ip, port, options, miscptr, fp); next_run = start_afp(sock, ip, port, options, miscptr, fp);
@ -172,13 +170,13 @@ void service_afp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
#endif #endif
int32_t service_afp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_afp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -1,17 +1,16 @@
//This plugin was written by david@ // This plugin was written by david@
// //
//This plugin is written for Asterisk Call Manager // This plugin is written for Asterisk Call Manager
//which is running by default on TCP/5038 // which is running by default on TCP/5038
// //
#include "hydra-mod.h" #include "hydra-mod.h"
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_asterisk(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_asterisk(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\""; char *empty = "\"\"";
char *login, *pass, buffer[1024]; char *login, *pass, buffer[1024];
@ -41,7 +40,10 @@ int32_t start_asterisk(int32_t s, char *ip, int32_t port, unsigned char options,
hydra_report(stderr, "[DEBUG] S: %s\n", buf); hydra_report(stderr, "[DEBUG] S: %s\n", buf);
if (buf == NULL || (strstr(buf, "Response: ") == NULL)) { if (buf == NULL || (strstr(buf, "Response: ") == NULL)) {
hydra_report(stderr, "[ERROR] Asterisk Call Manager protocol error or service shutdown: %s\n", buf); hydra_report(stderr,
"[ERROR] Asterisk Call Manager protocol error or service "
"shutdown: %s\n",
buf);
free(buf); free(buf);
return 4; return 4;
} }
@ -62,7 +64,7 @@ int32_t start_asterisk(int32_t s, char *ip, int32_t port, unsigned char options,
return 2; return 2;
} }
void service_asterisk(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_asterisk(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ASTERISK, mysslport = PORT_ASTERISK_SSL; int32_t myport = PORT_ASTERISK, mysslport = PORT_ASTERISK_SSL;
@ -71,10 +73,10 @@ void service_asterisk(char *ip, int32_t sp, unsigned char options, char *miscptr
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -89,31 +91,35 @@ void service_asterisk(char *ip, int32_t sp, unsigned char options, char *miscptr
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
//fprintf(stderr, "%s\n",buf); // fprintf(stderr, "%s\n",buf);
//banner should look like: // banner should look like:
//Asterisk Call Manager/1.1 // Asterisk Call Manager/1.1
if (buf == NULL || strstr(buf, "Asterisk Call Manager/") == NULL) { if (buf == NULL || strstr(buf, "Asterisk Call Manager/") == NULL) {
/* check the first line */ /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an Asterisk Call Manager protocol or service shutdown: %s\n", buf); hydra_report(stderr,
"[ERROR] Not an Asterisk Call Manager protocol or "
"service shutdown: %s\n",
buf);
hydra_child_exit(2); hydra_child_exit(2);
} }
free(buf); free(buf);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_asterisk(sock, ip, port, options, miscptr, fp); next_run = start_asterisk(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
break;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
@ -122,13 +128,13 @@ void service_asterisk(char *ip, int32_t sp, unsigned char options, char *miscptr
} }
} }
int32_t service_asterisk_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_asterisk_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -3,7 +3,7 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_cisco_enable(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_cisco_enable(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *pass, buffer[300]; char *pass, buffer[300];
@ -42,8 +42,7 @@ int32_t start_cisco_enable(int32_t s, char *ip, int32_t port, unsigned char opti
} }
} }
if (buf != NULL if (buf != NULL && (strstr(buf, "assw") != NULL || strstr(buf, "ad ") != NULL || strstr(buf, "attempt") != NULL || strstr(buf, "fail") != NULL || strstr(buf, "denied") != NULL)) {
&& (strstr(buf, "assw") != NULL || strstr(buf, "ad ") != NULL || strstr(buf, "attempt") != NULL || strstr(buf, "fail") != NULL || strstr(buf, "denied") != NULL)) {
free(buf); free(buf);
hydra_completed_pair(); hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
@ -58,7 +57,7 @@ int32_t start_cisco_enable(int32_t s, char *ip, int32_t port, unsigned char opti
return 3; return 3;
} }
void service_cisco_enable(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_cisco_enable(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, failc = 0, retry = 1, next_run = 1, sock = -1; int32_t run = 1, failc = 0, retry = 1, next_run = 1, sock = -1;
int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL; int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL;
char buffer[300]; char buffer[300];
@ -70,117 +69,130 @@ void service_cisco_enable(char *ip, int32_t sp, unsigned char options, char *mis
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
hydra_child_exit(1); fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
/* Cisco AAA Support */
if (strlen(login = hydra_get_next_login()) != 0) {
while ((buf = hydra_receive_line(sock)) != NULL && strstr(buf, "name:") == NULL && strstr(buf, "ogin:") == NULL) {
if (hydra_strcasestr(buf, "ress ENTER") != NULL)
hydra_send(sock, "\r\n", 2, 0);
free(buf);
} }
/* Cisco AAA Support */ sprintf(buffer, "%.250s\r\n", login);
if (strlen(login = hydra_get_next_login()) != 0) { if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
while ((buf = hydra_receive_line(sock)) != NULL && strstr(buf, "name:") == NULL && strstr(buf, "ogin:") == NULL) { if (quiet != 1)
if (hydra_strcasestr(buf, "ress ENTER") != NULL) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send login\n", (int32_t)getpid());
hydra_send(sock, "\r\n", 2, 0); hydra_child_exit(2);
free(buf);
}
sprintf(buffer, "%.250s\r\n", login);
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send login\n", (int32_t) getpid());
hydra_child_exit(2);
}
}
if (miscptr != NULL) {
if (buf != NULL)
free(buf);
while ((buf = hydra_receive_line(sock)) != NULL && strstr(buf, "assw") == NULL) {
if (hydra_strcasestr(buf, "ress ENTER") != NULL)
hydra_send(sock, "\r\n", 2, 0);
free(buf);
}
sprintf(buffer, "%.250s\r\n", miscptr);
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send login\n", (int32_t) getpid());
hydra_child_exit(2);
}
} }
}
if (miscptr != NULL) {
if (buf != NULL) if (buf != NULL)
free(buf); free(buf);
buf = hydra_receive_line(sock); while ((buf = hydra_receive_line(sock)) != NULL && strstr(buf, "assw") == NULL) {
if (hydra_strcasestr(buf, "ress ENTER") != NULL) { if (hydra_strcasestr(buf, "ress ENTER") != NULL)
hydra_send(sock, "\r\n", 2, 0); hydra_send(sock, "\r\n", 2, 0);
free(buf); free(buf);
buf = hydra_receive_line(sock);
} }
if (strstr(buf, "assw") != NULL) { sprintf(buffer, "%.250s\r\n", miscptr);
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating - can not login, can not login\n", (int32_t) getpid());
hydra_child_exit(2);
}
free(buf);
next_run = 2;
break;
}
case 2: /* run the cracking function */
{
unsigned char *buf2;
int32_t f = 0;
sprintf(buffer, "%.250s\r\n", "ena");
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) { if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send 'ena'\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send login\n", (int32_t)getpid());
hydra_child_exit(2); hydra_child_exit(2);
} }
do {
if (f != 0)
free(buf2);
else
f = 1;
if ((buf2 = (unsigned char *) hydra_receive_line(sock)) == NULL) {
if (failc < retry) {
next_run = 1;
failc++;
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d was disconnected - retrying (%d of %d retries)\n", (int32_t) getpid(), failc, retry);
sleep(3);
break;
} else {
fprintf(stderr, "[ERROR] Child with pid %d was disconnected - exiting\n", (int32_t) getpid());
hydra_child_exit(0);
}
}
} while (strstr((char *) buf2, "assw") == NULL);
free(buf2);
if (next_run != 0)
break;
failc = 0;
next_run = start_cisco_enable(sock, ip, port, options, miscptr, fp);
break;
} }
case 3: /* clean exit */
if (buf != NULL)
free(buf);
buf = hydra_receive_line(sock);
if (hydra_strcasestr(buf, "ress ENTER") != NULL) {
hydra_send(sock, "\r\n", 2, 0);
free(buf);
buf = hydra_receive_line(sock);
}
if (strstr(buf, "assw") != NULL) {
if (quiet != 1)
fprintf(stderr,
"[ERROR] Child with pid %d terminating - can not login, can "
"not login\n",
(int32_t)getpid());
hydra_child_exit(2);
}
free(buf);
next_run = 2;
break;
}
case 2: /* run the cracking function */
{
unsigned char *buf2;
int32_t f = 0;
sprintf(buffer, "%.250s\r\n", "ena");
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send 'ena'\n", (int32_t)getpid());
hydra_child_exit(2);
}
do {
if (f != 0)
free(buf2);
else
f = 1;
if ((buf2 = (unsigned char *)hydra_receive_line(sock)) == NULL) {
if (failc < retry) {
next_run = 1;
failc++;
if (quiet != 1)
fprintf(stderr,
"[ERROR] Child with pid %d was disconnected - retrying "
"(%d of %d retries)\n",
(int32_t)getpid(), failc, retry);
sleep(3);
break;
} else {
fprintf(stderr, "[ERROR] Child with pid %d was disconnected - exiting\n", (int32_t)getpid());
hydra_child_exit(0);
}
}
} while (strstr((char *)buf2, "assw") == NULL);
free(buf2);
if (next_run != 0)
break;
failc = 0;
next_run = start_cisco_enable(sock, ip, port, options, miscptr, fp);
break;
}
case 3: /* clean exit */
sprintf(buffer, "%.250s\r\n", "exit"); sprintf(buffer, "%.250s\r\n", "exit");
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) { if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send 'exit'\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not send 'exit'\n", (int32_t)getpid());
hydra_child_exit(0); hydra_child_exit(0);
} }
if (sock >= 0) if (sock >= 0)
@ -196,13 +208,13 @@ void service_cisco_enable(char *ip, int32_t sp, unsigned char options, char *mis
} }
} }
int32_t service_cisco_enable_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_cisco_enable_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -210,12 +222,16 @@ int32_t service_cisco_enable_init(char *ip, int32_t sp, unsigned char options, c
return 0; return 0;
} }
void usage_cisco_enable(const char* service) { void usage_cisco_enable(const char *service) {
printf("Module cisco-enable is optionally taking the logon password for the cisco device\n" printf("Module cisco-enable is optionally taking the logon password for the "
"Note: if AAA authentication is used, use the -l option for the username\n" "cisco device\n"
"Note: if AAA authentication is used, use the -l option for the "
"username\n"
"and the optional parameter for the password of the user.\n" "and the optional parameter for the password of the user.\n"
"Examples:\n" "Examples:\n"
" hydra -P pass.txt target cisco-enable (direct console access)\n" " hydra -P pass.txt target cisco-enable (direct console access)\n"
" hydra -P pass.txt -m cisco target cisco-enable (Logon password cisco)\n" " hydra -P pass.txt -m cisco target cisco-enable (Logon password "
" hydra -l foo -m bar -P pass.txt target cisco-enable (AAA Login foo, password bar)\n"); "cisco)\n"
" hydra -l foo -m bar -P pass.txt target cisco-enable (AAA Login "
"foo, password bar)\n");
} }

View file

@ -5,9 +5,9 @@
#endif #endif
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf = NULL; static char *buf = NULL;
int32_t start_cisco(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_cisco(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *pass, buffer[300]; char *pass, buffer[300];
@ -52,7 +52,7 @@ int32_t start_cisco(int32_t s, char *ip, int32_t port, unsigned char options, ch
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1; return 1;
} }
buf = NULL; buf = NULL;
do { do {
if (buf != NULL) if (buf != NULL)
@ -95,7 +95,6 @@ int32_t start_cisco(int32_t s, char *ip, int32_t port, unsigned char options, ch
} }
} while (buf != NULL && strlen(buf) <= 1); } while (buf != NULL && strlen(buf) <= 1);
} }
} }
if (buf != NULL && (strstr(buf, "assw") != NULL || strstr(buf, "ad ") != NULL || strstr(buf, "attempt") != NULL || strstr(buf, "ailur") != NULL)) { if (buf != NULL && (strstr(buf, "assw") != NULL || strstr(buf, "ad ") != NULL || strstr(buf, "attempt") != NULL || strstr(buf, "ailur") != NULL)) {
@ -115,7 +114,7 @@ int32_t start_cisco(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, failc = 0, retry = 1, next_run = 1, sock = -1; int32_t run = 1, failc = 0, retry = 1, next_run = 1, sock = -1;
int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL; int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL;
@ -125,63 +124,68 @@ void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, F
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
unsigned char *buf2 = NULL; unsigned char *buf2 = NULL;
int32_t f = 0; int32_t f = 0;
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
if (miscptr != NULL && hydra_strcasestr(miscptr, "enter") != NULL) if (miscptr != NULL && hydra_strcasestr(miscptr, "enter") != NULL)
hydra_send(sock, "\r\n", 2, 0); hydra_send(sock, "\r\n", 2, 0);
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
do {
if (f != 0) {
free(buf2);
buf2 = NULL;
} else
f = 1;
if ((buf2 = (unsigned char *) hydra_receive_line(sock)) == NULL) {
if (failc < retry) {
next_run = 1;
failc++;
if (quiet != 1) hydra_report(stderr, "[ERROR] Child with pid %d was disconnected - retrying (%d of %d retries)\n", (int32_t) getpid(), failc, retry);
sleep(3);
break;
} else {
if (quiet != 1) hydra_report(stderr, "[ERROR] Child with pid %d was disconnected - exiting\n", (int32_t) getpid());
hydra_child_exit(0);
}
}
if (buf2 != NULL && hydra_strcasestr((char*)buf2, "ress ENTER") != NULL)
hydra_send(sock, "\r\n", 2, 0);
} while (buf2 != NULL && strstr((char *) buf2, "assw") == NULL);
free(buf2);
if (next_run != 0)
break;
failc = 0;
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
do {
if (f != 0) {
free(buf2);
buf2 = NULL;
} else
f = 1;
if ((buf2 = (unsigned char *)hydra_receive_line(sock)) == NULL) {
if (failc < retry) {
next_run = 1;
failc++;
if (quiet != 1)
hydra_report(stderr,
"[ERROR] Child with pid %d was disconnected - "
"retrying (%d of %d retries)\n",
(int32_t)getpid(), failc, retry);
sleep(3);
break;
} else {
if (quiet != 1)
hydra_report(stderr, "[ERROR] Child with pid %d was disconnected - exiting\n", (int32_t)getpid());
hydra_child_exit(0);
}
}
if (buf2 != NULL && hydra_strcasestr((char *)buf2, "ress ENTER") != NULL)
hydra_send(sock, "\r\n", 2, 0);
} while (buf2 != NULL && strstr((char *)buf2, "assw") == NULL);
free(buf2);
if (next_run != 0)
break;
failc = 0;
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_cisco(sock, ip, port, options, miscptr, fp); next_run = start_cisco(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -199,13 +203,13 @@ void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, F
} }
} }
int32_t service_cisco_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_cisco_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -213,6 +217,8 @@ int32_t service_cisco_init(char *ip, int32_t sp, unsigned char options, char *mi
return 0; return 0;
} }
void usage_cisco(const char* service) { void usage_cisco(const char *service) {
printf("Module cisco is optionally taking the keyword ENTER, it then sends an initial\n" "ENTER when connecting to the service.\n"); printf("Module cisco is optionally taking the keyword ENTER, it then sends "
"an initial\n"
"ENTER when connecting to the service.\n");
} }

126
hydra-cobaltstrike.c Normal file
View file

@ -0,0 +1,126 @@
#include "hydra-mod.h"
#define CSLEN 256
extern char *HYDRA_EXIT;
char *buf;
int32_t start_cobaltstrike(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "";
char *pass, buffer[4 + 1 + 256];
char cs_pass[CSLEN + 1];
unsigned char len_pass;
unsigned char reply_byte_0;
unsigned char reply_byte_1;
unsigned char reply_byte_2;
unsigned char reply_byte_3;
int32_t ret = -1;
if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty;
if (strlen(pass) > CSLEN)
pass[CSLEN - 1] = 0;
len_pass = strlen(pass);
memset(cs_pass, 0, CSLEN + 1);
strcpy(cs_pass, pass);
memset(buffer, 0x41, sizeof(buffer));
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = 0xBE;
buffer[3] = 0xEF;
memcpy(buffer + 4, &len_pass, 1);
memcpy(buffer + 5, cs_pass, len_pass);
if (hydra_send(s, buffer, sizeof(buffer), 0) < 0)
return 1;
reply_byte_0 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_0, 1);
if (ret <= 0)
return 3;
reply_byte_1 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_1, 1);
if (ret <= 0)
return 3;
reply_byte_2 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_2, 1);
if (ret <= 0)
return 3;
reply_byte_3 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_3, 1);
if (ret <= 0)
return 3;
if (reply_byte_0 == 0x00 && reply_byte_1 == 0x00 && reply_byte_2 == 0xCA && reply_byte_3 == 0xFE) {
hydra_report_found_host(port, ip, "cobaltstrike", fp);
hydra_completed_pair_found();
free(buf);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 2;
return 1;
}
free(buf);
hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 2;
return 1;
}
void service_cobaltstrike(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1;
int32_t mysslport = PORT_COBALTSTRIKE_SSL;
hydra_register_socket(sp);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return;
while (1) {
switch (run) {
case 1: /* connect and service init function */
if (port != 0)
mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport;
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = start_cobaltstrike(sock, ip, port, options, miscptr, fp);
hydra_disconnect(sock);
break;
case 2: /* clean exit */
if (sock >= 0)
sock = hydra_disconnect(sock);
hydra_child_exit(0);
return;
case 3: /* clean exit */
if (sock >= 0)
sock = hydra_disconnect(sock);
hydra_child_exit(2);
return;
default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2);
}
run = next_run;
}
}
int32_t service_cobaltstrike_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be
// performed once only.
//
// fill if needed.
//
// return codes:
// 0 all OK
// -1 error, hydra will exit, so print a good error message here
return 0;
}

View file

@ -5,38 +5,32 @@ extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_cvs(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_cvs(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[1024], pass2[513]; char *login, *pass, buffer[1024], pass2[513];
int32_t i; int32_t i;
char *directory = miscptr; char *directory = miscptr;
/* evil cvs encryption sheme... /* evil cvs encryption sheme...
0 111 P 125 p 58 0 111 P 125 p 58
! 120 1 52 A 57 Q 55 a 121 q 113 ! 120 1 52 A 57 Q 55 a 121 q 113
" 53 2 75 B 83 R 54 b 117 r 32 " 53 2 75 B 83 R 54 b 117 r 32
3 119 C 43 S 66 c 104 s 90 3 119 C 43 S 66 c 104 s 90
4 49 D 46 T 124 d 101 t 44 4 49 D 46 T 124 d 101 t 44
% 109 5 34 E 102 U 126 e 100 u 98 % 109 5 34 E 102 U 126 e 100 u 98
& 72 6 82 F 40 V 59 f 69 v 60 & 72 6 82 F 40 V 59 f 69 v 60
' 108 7 81 G 89 W 47 g 73 w 51 ' 108 7 81 G 89 W 47 g 73 w 51
( 70 8 95 H 38 X 92 h 99 x 33 ( 70 8 95 H 38 X 92 h 99 x 33
) 64 9 65 I 103 Y 71 i 63 y 97 ) 64 9 65 I 103 Y 71 i 63 y 97
* 76 : 112 J 45 Z 115 j 94 z 62 * 76 : 112 J 45 Z 115 j 94 z 62
+ 67 ; 86 K 50 k 93 + 67 ; 86 K 50 k 93
, 116 < 118 L 42 l 39 , 116 < 118 L 42 l 39
- 74 = 110 M 123 m 37 - 74 = 110 M 123 m 37
. 68 > 122 N 91 n 61 . 68 > 122 N 91 n 61
/ 87 ? 105 O 35 _ 56 o 48 / 87 ? 105 O 35 _ 56 o 48
*/ */
char key[] = { 0, 120, 53, 0, 0, 109, 72, 108, 70, 64, 76, 67, 116, 74, 68, 87, char key[] = {0, 120, 53, 0, 0, 109, 72, 108, 70, 64, 76, 67, 116, 74, 68, 87, 111, 52, 75, 119, 49, 34, 82, 81, 95, 65, 112, 86, 118, 110, 122, 105, 0, 57, 83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35, 125, 55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 0, 0, 0, 0, 56, 0, 121, 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48, 58, 113, 32, 90, 44, 98, 60, 51, 33, 97, 62};
111, 52, 75, 119, 49, 34, 82, 81, 95, 65, 112, 86, 118, 110, 122, 105,
0, 57, 83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35,
125, 55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 0, 0, 0, 0, 56,
0, 121, 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
58, 113, 32, 90, 44, 98, 60, 51, 33, 97, 62
};
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
@ -85,7 +79,7 @@ int32_t start_cvs(int32_t s, char *ip, int32_t port, unsigned char options, char
return 3; return 3;
} }
void service_cvs(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_cvs(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_CVS, mysslport = PORT_CVS_SSL; int32_t myport = PORT_CVS, mysslport = PORT_CVS_SSL;
@ -100,11 +94,11 @@ void service_cvs(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -118,12 +112,12 @@ void service_cvs(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = start_cvs(sock, ip, port, options, miscptr, fp); next_run = start_cvs(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -136,13 +130,13 @@ void service_cvs(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
} }
int32_t service_cvs_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_cvs_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -150,6 +144,7 @@ int32_t service_cvs_init(char *ip, int32_t sp, unsigned char options, char *misc
return 0; return 0;
} }
void usage_cvs(const char* service) { void usage_cvs(const char *service) {
printf("Module cvs is optionally taking the repository name to attack, default is \"/root\"\n\n"); printf("Module cvs is optionally taking the repository name to attack, "
"default is \"/root\"\n\n");
} }

View file

@ -1,7 +1,7 @@
/* /*
Firebird Support - by David Maciejak @ GMAIL dot com Firebird Support - by David Maciejak @ GMAIL dot com
you need to pass full path to the fdb file as argument you need to pass full path to the fdb file as argument
default account is SYSDBA/masterkey default account is SYSDBA/masterkey
@ -14,28 +14,27 @@ the msg: "no permission for direct access to security database"
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBFIREBIRD #ifndef LIBFIREBIRD
void dummy_firebird() { void dummy_firebird() { printf("\n"); }
printf("\n");
}
#else #else
#include <stdio.h>
#include <ibase.h> #include <ibase.h>
#include <stdio.h>
#define DEFAULT_DB "C:\\Program Files\\Firebird\\Firebird_1_5\\security.fdb" #define DEFAULT_DB "C:\\Program Files\\Firebird\\Firebird_1_5\\security.fdb"
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
int32_t start_firebird(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_firebird(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
char database[256]; char database[256];
char connection_string[1024]; char connection_string[1024];
isc_db_handle db; /* database handle */ isc_db_handle db; /* database handle */
ISC_STATUS_ARRAY status; /* status vector */ ISC_STATUS_ARRAY status; /* status vector */
char *dpb = NULL; /* DB parameter buffer */ char *dpb = NULL; /* DB parameter buffer */
short dpb_length = 0; short dpb_length = 0;
if (miscptr) if (miscptr)
@ -49,8 +48,8 @@ int32_t start_firebird(int32_t s, char *ip, int32_t port, unsigned char options,
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty; pass = empty;
dpb_length = (short) (1 + strlen(login) + 2 + strlen(pass) + 2); dpb_length = (short)(1 + strlen(login) + 2 + strlen(pass) + 2);
if ((dpb = (char *) malloc(dpb_length)) == NULL) { if ((dpb = (char *)malloc(dpb_length)) == NULL) {
hydra_report(stderr, "[ERROR] Can't allocate memory\n"); hydra_report(stderr, "[ERROR] Can't allocate memory\n");
return 1; return 1;
} }
@ -86,7 +85,7 @@ int32_t start_firebird(int32_t s, char *ip, int32_t port, unsigned char options,
return 1; return 1;
} }
void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_FIREBIRD, mysslport = PORT_FIREBIRD_SSL; int32_t myport = PORT_FIREBIRD, mysslport = PORT_FIREBIRD_SSL;
@ -95,9 +94,8 @@ void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -112,7 +110,8 @@ void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -122,10 +121,12 @@ void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr
case 2: case 2:
/* /*
* Here we start the password cracking process * Here we start the password cracking process
*/ */
next_run = start_firebird(sock, ip, port, options, miscptr, fp); next_run = start_firebird(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: case 3:
@ -145,13 +146,13 @@ void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr
#endif #endif
int32_t service_firebird_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_firebird_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -159,6 +160,8 @@ int32_t service_firebird_init(char *ip, int32_t sp, unsigned char options, char
return 0; return 0;
} }
void usage_firebird(const char* service) { void usage_firebird(const char *service) {
printf("Module firebird is optionally taking the database path to attack,\n" "default is \"C:\\Program Files\\Firebird\\Firebird_1_5\\security.fdb\"\n\n"); printf("Module firebird is optionally taking the database path to attack,\n"
"default is \"C:\\Program "
"Files\\Firebird\\Firebird_1_5\\security.fdb\"\n\n");
} }

View file

@ -3,7 +3,7 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\""; char *empty = "\"\"";
char *login, *pass, buffer[510]; char *login, *pass, buffer[510];
@ -20,13 +20,16 @@ int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char
buf = hydra_receive_line(s); buf = hydra_receive_line(s);
if (buf == NULL) if (buf == NULL)
return 1; return 1;
/* special hack to identify 530 user unknown msg. suggested by Jean-Baptiste.BEAUFRETON@turbomeca.fr */ /* special hack to identify 530 user unknown msg. suggested by
* Jean-Baptiste.BEAUFRETON@turbomeca.fr */
if (buf[0] == '5' && buf[1] == '3' && buf[2] == '0') { if (buf[0] == '5' && buf[1] == '3' && buf[2] == '0') {
if (verbose) if (verbose)
printf("[INFO] user %s does not exist, skipping\n", login); printf("[INFO] user %s does not exist, skipping\n", login);
hydra_completed_pair_skip(); hydra_completed_pair_skip();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
free(buf);
return 4; return 4;
}
free(buf); free(buf);
return 1; return 1;
} }
@ -34,8 +37,10 @@ int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char
if (buf[0] == '2') { if (buf[0] == '2') {
hydra_report_found_host(port, ip, "ftp", fp); hydra_report_found_host(port, ip, "ftp", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
free(buf);
return 4; return 4;
}
free(buf); free(buf);
return 1; return 1;
} }
@ -60,8 +65,10 @@ int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char
if (buf[0] == '2') { if (buf[0] == '2') {
hydra_report_found_host(port, ip, "ftp", fp); hydra_report_found_host(port, ip, "ftp", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
free(buf);
return 4; return 4;
}
free(buf); free(buf);
return 1; return 1;
} }
@ -74,7 +81,7 @@ int32_t start_ftp(int32_t s, char *ip, int32_t port, unsigned char options, char
return 2; return 2;
} }
void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname, int32_t tls) { void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname, int32_t tls) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_FTP, mysslport = PORT_FTP_SSL; int32_t myport = PORT_FTP, mysslport = PORT_FTP_SSL;
@ -83,10 +90,10 @@ void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr
hydra_child_exit(0); hydra_child_exit(0);
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -100,12 +107,12 @@ void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
usleepn(250); usleepn(250);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '2') { /* check the first line */ if (buf == NULL || buf[0] != '2') { /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an FTP protocol or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] Not an FTP protocol or service shutdown: %s\n", buf);
hydra_child_exit(2); hydra_child_exit(2);
@ -120,7 +127,7 @@ void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr
} }
free(buf); free(buf);
//this mode is manually chosen, so if it fails we giving up // this mode is manually chosen, so if it fails we giving up
if (tls) { if (tls) {
if (hydra_send(sock, "AUTH TLS\r\n", strlen("AUTH TLS\r\n"), 0) < 0) { if (hydra_send(sock, "AUTH TLS\r\n", strlen("AUTH TLS\r\n"), 0) < 0) {
hydra_child_exit(2); hydra_child_exit(2);
@ -148,17 +155,19 @@ void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_ftp(sock, ip, port, options, miscptr, fp); next_run = start_ftp(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* error exit */ case 3: /* error exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
case 4: /* clean exit */ break;
case 4: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
break;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
@ -167,21 +176,17 @@ void service_ftp_core(char *ip, int32_t sp, unsigned char options, char *miscptr
} }
} }
void service_ftp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ftp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ftp_core(ip, sp, options, miscptr, fp, port, hostname, 0); }
service_ftp_core(ip, sp, options, miscptr, fp, port, hostname, 0);
}
void service_ftps(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ftps(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ftp_core(ip, sp, options, miscptr, fp, port, hostname, 1); }
service_ftp_core(ip, sp, options, miscptr, fp, port, hostname, 1);
}
int32_t service_ftp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_ftp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -61,8 +61,9 @@ CC = @CC@
MAINT = @MAINT@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ -fcommon -Wl,--allow-multiple-definition
PACKAGE_LIBS = @PACKAGE_LIBS@ PACKAGE_LDFLAGS = -fcommon -Wl,--allow-multiple-definition
PACKAGE_LIBS = -fcommon -Wl,--allow-multiple-definition @PACKAGE_LIBS@
PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG = @PKG_CONFIG@
VERSION = @VERSION@ VERSION = @VERSION@

16
hydra-gtk/configure vendored
View file

@ -2233,15 +2233,15 @@ if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then if test "$GCC" = yes; then
CFLAGS="-g -O2" CFLAGS="-g -O2 -fcommon -Wl,--allow-multiple-definition"
else else
CFLAGS="-g" CFLAGS="-g -fcommon -Wl,--allow-multiple-definition"
fi fi
else else
if test "$GCC" = yes; then if test "$GCC" = yes; then
CFLAGS="-O2" CFLAGS="-O2 -fcommon -Wl,--allow-multiple-definition"
else else
CFLAGS= CFLAGS="-fcommon -Wl,--allow-multiple-definition"
fi fi
fi fi
echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
@ -2391,7 +2391,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
for ac_declaration in \ for ac_declaration in \
'' \ '#include <stdlib.h>' \
'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \
'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int) throw ();' \
@ -3192,7 +3192,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
for ac_declaration in \ for ac_declaration in \
'' \ '#include <stdlib.h>' \
'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \
'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int) throw ();' \
@ -3797,8 +3797,8 @@ main ()
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i)) || toupper (i) != TOUPPER (i))
exit(2); return 2;
exit (0); return 0;
} }
_ACEOF _ACEOF
rm -f conftest$ac_exeext rm -f conftest$ac_exeext

View file

@ -10,7 +10,7 @@ AC_PROG_CC
AM_PROG_CC_STDC AM_PROG_CC_STDC
AC_HEADER_STDC AC_HEADER_STDC
pkg_modules="gtk+-2.0 >= 2.0.0" pkg_modules="gtk+-3.0 >= 3.24.24"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS) AC_SUBST(PACKAGE_LIBS)

View file

@ -61,8 +61,8 @@ CC = @CC@
MAINT = @MAINT@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ -fcommon -Wl,--allow-multiple-definition
PACKAGE_LIBS = @PACKAGE_LIBS@ PACKAGE_LIBS = -fcommon -Wl,--allow-multiple-definition @PACKAGE_LIBS@
PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG = @PKG_CONFIG@
VERSION = @VERSION@ VERSION = @VERSION@

View file

@ -1,7 +1,7 @@
/* /*
* This file handles all that needs to be done... * This file handles all that needs to be done...
* Some stuff is stolen from gcombust since I never used pipes... ok, i * Some stuff is stolen from gcombust since I never used pipes... ok, i
* only used them in reallife :) * only used them in reallife :)
*/ */
@ -15,38 +15,35 @@
#include "interface.h" #include "interface.h"
#include "support.h" #include "support.h"
#include <sys/types.h> #include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/wait.h>
#include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h> #include <string.h>
#include <unistd.h>
int hydra_pid = 0; int hydra_pid = 0;
char port[10]; char port[10];
char tasks[10]; char tasks[10];
char timeout[10]; char timeout[10];
char smbparm[12]; char smbparm[128];
char sapr3id[4]; char sapr3id[4];
char passLoginNull[4]; char passLoginNull[4];
#define BUF_S 1024 #define BUF_S 1024
void hydra_select_file(GtkEntry * widget, char *text) { void hydra_select_file(GtkEntry *widget, char *text) {
#ifdef GTK_TYPE_FILE_CHOOSER #ifdef GTK_TYPE_FILE_CHOOSER
GtkWidget *dialog; GtkWidget *dialog;
char *filename; char *filename;
dialog = gtk_file_chooser_dialog_new(text, (GtkWindow *) wndMain, GTK_FILE_CHOOSER_ACTION_OPEN, dialog = gtk_file_chooser_dialog_new(text, (GtkWindow *)wndMain, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
@ -70,7 +67,7 @@ int hydra_get_options(char *options[]) {
/* get the port */ /* get the port */
widget = lookup_widget(GTK_WIDGET(wndMain), "spnPort"); widget = lookup_widget(GTK_WIDGET(wndMain), "spnPort");
j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget); j = gtk_spin_button_get_value_as_int((GtkSpinButton *)widget);
if (j != 0) { if (j != 0) {
snprintf(port, 10, "%d", j); snprintf(port, 10, "%d", j);
options[i++] = "-s"; options[i++] = "-s";
@ -79,107 +76,107 @@ int hydra_get_options(char *options[]) {
/* prefer ipv6 */ /* prefer ipv6 */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkIPV6"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkIPV6");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-6"; options[i++] = "-6";
} }
/* use SSL? */ /* use SSL? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkSSL"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkSSL");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-S"; options[i++] = "-S";
} }
/* use old SSL? */ /* use old SSL? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkOldSSL"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkOldSSL");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-O"; options[i++] = "-O";
} }
/* be verbose? */ /* be verbose? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkVerbose"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkVerbose");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-v"; options[i++] = "-v";
} }
/* show attempts */ /* show attempts */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkAttempts"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkAttempts");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-V"; options[i++] = "-V";
} }
/* debug mode? */ /* debug mode? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkDebug"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkDebug");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-d"; options[i++] = "-d";
} }
/* COMPLETE HELP */ /* COMPLETE HELP */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkCompleteHelp"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkCompleteHelp");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-h"; options[i++] = "-h";
} }
/* Service Module Usage Details */ /* Service Module Usage Details */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkServiceDetails"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkServiceDetails");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-U"; options[i++] = "-U";
} }
/* use colon separated list? */ /* use colon separated list? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkColon"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkColon");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-C"; options[i++] = "-C";
widget = lookup_widget(GTK_WIDGET(wndMain), "entColonFile"); widget = lookup_widget(GTK_WIDGET(wndMain), "entColonFile");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else { } else {
/* disable usernames */ /* disable usernames */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkDisUser"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkDisUser");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
} else { } else {
/* get the username, or username list */ /* get the username, or username list */
widget = lookup_widget(GTK_WIDGET(wndMain), "radioUsername1"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioUsername1");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-l"; options[i++] = "-l";
widget = lookup_widget(GTK_WIDGET(wndMain), "entUsername"); widget = lookup_widget(GTK_WIDGET(wndMain), "entUsername");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else { } else {
options[i++] = "-L"; options[i++] = "-L";
widget = lookup_widget(GTK_WIDGET(wndMain), "entUsernameFile"); widget = lookup_widget(GTK_WIDGET(wndMain), "entUsernameFile");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
} }
/* get the pass, pass list, or generate */ /* get the pass, pass list, or generate */
/* The "generate" button was implemented by Petar Kaleychev <petar.kaleychev@gmail.com> */ /* The "generate" button was implemented by Petar Kaleychev <petar.kaleychev@gmail.com> */
widget = lookup_widget(GTK_WIDGET(wndMain), "radioPass1"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioPass1");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-p"; options[i++] = "-p";
widget = lookup_widget(GTK_WIDGET(wndMain), "entPass"); widget = lookup_widget(GTK_WIDGET(wndMain), "entPass");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
widget = lookup_widget(GTK_WIDGET(wndMain), "radioPass2"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioPass2");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-P"; options[i++] = "-P";
widget = lookup_widget(GTK_WIDGET(wndMain), "entPassFile"); widget = lookup_widget(GTK_WIDGET(wndMain), "entPassFile");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
widget = lookup_widget(GTK_WIDGET(wndMain), "radioGenerate"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioGenerate");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-x"; options[i++] = "-x";
widget = lookup_widget(GTK_WIDGET(wndMain), "entGeneration"); widget = lookup_widget(GTK_WIDGET(wndMain), "entGeneration");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
} }
/* empty passes / login as pass / reversed login? */ /* empty passes / login as pass / reversed login? */
memset(passLoginNull, 0, 4); memset(passLoginNull, 0, 4);
widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassNull"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassNull");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
passLoginNull[0] = 'n'; passLoginNull[0] = 'n';
} }
widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassLogin"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassLogin");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
if (passLoginNull[0] == 0) { if (passLoginNull[0] == 0) {
passLoginNull[0] = 's'; passLoginNull[0] = 's';
} else { } else {
@ -188,7 +185,7 @@ int hydra_get_options(char *options[]) {
} }
/* The "Try reversed login" button was implemented by Petar Kaleychev <petar.kaleychev@gmail.com> */ /* The "Try reversed login" button was implemented by Petar Kaleychev <petar.kaleychev@gmail.com> */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassReverse"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassReverse");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
if (passLoginNull[0] == 0) { if (passLoginNull[0] == 0) {
passLoginNull[0] = 'r'; passLoginNull[0] = 'r';
} else if (passLoginNull[1] == 0) { } else if (passLoginNull[1] == 0) {
@ -204,7 +201,7 @@ int hydra_get_options(char *options[]) {
/* #of tasks */ /* #of tasks */
widget = lookup_widget(GTK_WIDGET(wndMain), "spnTasks"); widget = lookup_widget(GTK_WIDGET(wndMain), "spnTasks");
j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget); j = gtk_spin_button_get_value_as_int((GtkSpinButton *)widget);
if (j != 40) { if (j != 40) {
snprintf(tasks, 10, "%d", j); snprintf(tasks, 10, "%d", j);
options[i++] = "-t"; options[i++] = "-t";
@ -213,7 +210,7 @@ int hydra_get_options(char *options[]) {
/* timeout */ /* timeout */
widget = lookup_widget(GTK_WIDGET(wndMain), "spnTimeout"); widget = lookup_widget(GTK_WIDGET(wndMain), "spnTimeout");
j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget); j = gtk_spin_button_get_value_as_int((GtkSpinButton *)widget);
if (j != 30) { if (j != 30) {
snprintf(timeout, 10, "%d", j); snprintf(timeout, 10, "%d", j);
options[i++] = "-w"; options[i++] = "-w";
@ -222,59 +219,59 @@ int hydra_get_options(char *options[]) {
/* loop around users? */ /* loop around users? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkUsernameLoop"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkUsernameLoop");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-u"; options[i++] = "-u";
} }
/* exit after first found pair? */ /* exit after first found pair? */
/* per host */ /* per host */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkExitf"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkExitf");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-f"; options[i++] = "-f";
} }
/* global */ /* global */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkExitF"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkExitF");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-F"; options[i++] = "-F";
} }
/* Do not print messages about connection errors */ /* Do not print messages about connection errors */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkNoErr"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkNoErr");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
options[i++] = "-q"; options[i++] = "-q";
} }
/* get additional parameters */ /* get additional parameters */
widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol"); widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol");
tmp = (char *) gtk_entry_get_text((GtkEntry *) widget); tmp = (char *)gtk_entry_get_text((GtkEntry *)widget);
if (!strncmp(tmp, "http-proxy", 10)) { if (!strncmp(tmp, "http-proxy", 10)) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxyURL"); widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxyURL");
options[i++] = "-m"; options[i++] = "-m";
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strncmp(tmp, "http-", 5) || !strncmp(tmp, "https-", 6)) { } else if (!strncmp(tmp, "http-", 5) || !strncmp(tmp, "https-", 6)) {
options[i++] = "-m"; options[i++] = "-m";
widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPURL"); widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPURL");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "cisco-enable")) { } else if (!strcmp(tmp, "cisco-enable")) {
options[i++] = "-m"; options[i++] = "-m";
widget = lookup_widget(GTK_WIDGET(wndMain), "entCiscoPass"); widget = lookup_widget(GTK_WIDGET(wndMain), "entCiscoPass");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "ldap3-crammd5")) { } else if (!strcmp(tmp, "ldap3-crammd5")) {
options[i++] = "-m"; options[i++] = "-m";
widget = lookup_widget(GTK_WIDGET(wndMain), "entLDAPDN"); widget = lookup_widget(GTK_WIDGET(wndMain), "entLDAPDN");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "ldap3-digestmd5")) { } else if (!strcmp(tmp, "ldap3-digestmd5")) {
options[i++] = "-m"; options[i++] = "-m";
widget = lookup_widget(GTK_WIDGET(wndMain), "entLDAPDN"); widget = lookup_widget(GTK_WIDGET(wndMain), "entLDAPDN");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "smb")) { } else if (!strcmp(tmp, "smb")) {
memset(smbparm, 0, 12); memset(smbparm, 0, sizeof(smbparm));
widget = lookup_widget(GTK_WIDGET(wndMain), "chkDomain"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkDomain");
widget2 = lookup_widget(GTK_WIDGET(wndMain), "chkLocal"); widget2 = lookup_widget(GTK_WIDGET(wndMain), "chkLocal");
@ -282,12 +279,12 @@ int hydra_get_options(char *options[]) {
strncpy(smbparm, "Both", sizeof(smbparm)); strncpy(smbparm, "Both", sizeof(smbparm));
smbparm[strlen("Both")] = '\0'; smbparm[strlen("Both")] = '\0';
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
strncpy(smbparm, "Domain", sizeof(smbparm)); strncpy(smbparm, "Domain", sizeof(smbparm));
smbparm[strlen("Domain")] = '\0'; smbparm[strlen("Domain")] = '\0';
} }
if (gtk_toggle_button_get_active((GtkToggleButton *) widget2)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget2)) {
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
strncpy(smbparm, "Both", sizeof(smbparm)); strncpy(smbparm, "Both", sizeof(smbparm));
smbparm[strlen("Both")] = '\0'; smbparm[strlen("Both")] = '\0';
} else { } else {
@ -296,14 +293,25 @@ int hydra_get_options(char *options[]) {
} }
} }
widget = lookup_widget(GTK_WIDGET(wndMain), "chkNTLM"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkNTLM");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
strcat(smbparm, "Hash"); strcat(smbparm, "Hash");
} }
options[i++] = smbparm; options[i++] = smbparm;
} else if (!strcmp(tmp, "smb2")) {
memset(smbparm, 0, sizeof(smbparm));
options[i++] = "-m";
options[i++] = smbparm;
widget = lookup_widget(GTK_WIDGET(wndMain), "chkNTLM");
int pth = gtk_toggle_button_get_active((GtkToggleButton *)widget);
widget = lookup_widget(GTK_WIDGET(wndMain), "entSMB2Workgroup");
snprintf(smbparm, sizeof(smbparm) - 1, "nthash:%s workgroup:{%s}", pth ? "true" : "false", (char *)gtk_entry_get_text((GtkEntry *)widget));
} else if (!strcmp(tmp, "sapr3")) { } else if (!strcmp(tmp, "sapr3")) {
widget = lookup_widget(GTK_WIDGET(wndMain), "spnSAPR3"); widget = lookup_widget(GTK_WIDGET(wndMain), "spnSAPR3");
j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget); j = gtk_spin_button_get_value_as_int((GtkSpinButton *)widget);
snprintf(sapr3id, sizeof(sapr3id), "%d", j); snprintf(sapr3id, sizeof(sapr3id), "%d", j);
options[i++] = "-m"; options[i++] = "-m";
options[i++] = sapr3id; options[i++] = sapr3id;
@ -311,18 +319,18 @@ int hydra_get_options(char *options[]) {
} else if (!strcmp(tmp, "cvs") || !strcmp(tmp, "svn")) { } else if (!strcmp(tmp, "cvs") || !strcmp(tmp, "svn")) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entCVS"); widget = lookup_widget(GTK_WIDGET(wndMain), "entCVS");
options[i++] = "-m"; options[i++] = "-m";
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "snmp")) { } else if (!strcmp(tmp, "snmp")) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entSNMP"); widget = lookup_widget(GTK_WIDGET(wndMain), "entSNMP");
options[i++] = "-m"; options[i++] = "-m";
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else if (!strcmp(tmp, "telnet")) { } else if (!strcmp(tmp, "telnet")) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entTelnet"); widget = lookup_widget(GTK_WIDGET(wndMain), "entTelnet");
if ((char *) gtk_entry_get_text((GtkEntry *) widget) != NULL) { if ((char *)gtk_entry_get_text((GtkEntry *)widget) != NULL) {
options[i++] = "-m"; options[i++] = "-m";
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
} }
@ -334,45 +342,44 @@ int hydra_get_options(char *options[]) {
/* proxy support */ /* proxy support */
widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy");
if (!gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (!gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
widget2 = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxy"); widget2 = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxy");
widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy2"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy2");
/* which variable do we set? */ /* which variable do we set? */
if ((!strncmp(tmp, "http-", 5)) && (gtk_toggle_button_get_active((GtkToggleButton *) widget))) { if ((!strncmp(tmp, "http-", 5)) && (gtk_toggle_button_get_active((GtkToggleButton *)widget))) {
setenv("HYDRA_PROXY_HTTP", gtk_entry_get_text((GtkEntry *) widget2), 1); setenv("HYDRA_PROXY_HTTP", gtk_entry_get_text((GtkEntry *)widget2), 1);
} else { } else {
setenv("HYDRA_PROXY_CONNECT", (char *) gtk_entry_get_text((GtkEntry *) widget2), 1); setenv("HYDRA_PROXY_CONNECT", (char *)gtk_entry_get_text((GtkEntry *)widget2), 1);
} }
/* do we need to provide user and pass? */ /* do we need to provide user and pass? */
widget = lookup_widget(GTK_WIDGET(wndMain), "chkProxyAuth"); widget = lookup_widget(GTK_WIDGET(wndMain), "chkProxyAuth");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entProxyUser"); widget = lookup_widget(GTK_WIDGET(wndMain), "entProxyUser");
widget2 = lookup_widget(GTK_WIDGET(wndMain), "entProxyPass"); widget2 = lookup_widget(GTK_WIDGET(wndMain), "entProxyPass");
a = g_string_new((gchar *) gtk_entry_get_text((GtkEntry *) widget)); a = g_string_new((gchar *)gtk_entry_get_text((GtkEntry *)widget));
a = g_string_append_c(a, ':'); a = g_string_append_c(a, ':');
a = g_string_append(a, gtk_entry_get_text((GtkEntry *) widget2)); a = g_string_append(a, gtk_entry_get_text((GtkEntry *)widget2));
setenv("HYDRA_PROXY_AUTH", a->str, 1); setenv("HYDRA_PROXY_AUTH", a->str, 1);
(void) g_string_free(a, TRUE); (void)g_string_free(a, TRUE);
} }
} }
/* get the target, or target list */ /* get the target, or target list */
widget = lookup_widget(GTK_WIDGET(wndMain), "radioTarget1"); widget = lookup_widget(GTK_WIDGET(wndMain), "radioTarget1");
if (gtk_toggle_button_get_active((GtkToggleButton *) widget)) { if (gtk_toggle_button_get_active((GtkToggleButton *)widget)) {
widget = lookup_widget(GTK_WIDGET(wndMain), "entTarget"); widget = lookup_widget(GTK_WIDGET(wndMain), "entTarget");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} else { } else {
options[i++] = "-M"; options[i++] = "-M";
widget = lookup_widget(GTK_WIDGET(wndMain), "entTargetFile"); widget = lookup_widget(GTK_WIDGET(wndMain), "entTargetFile");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
} }
/* get the service */ /* get the service */
widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol"); widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol");
options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget); options[i++] = (char *)gtk_entry_get_text((GtkEntry *)widget);
options[i] = NULL; options[i] = NULL;
return i; return i;
@ -389,12 +396,11 @@ int update_statusbar() {
i = hydra_get_options(options); i = hydra_get_options(options);
for (j = 1; j < i; j++) { for (j = 1; j < i; j++) {
statustext = g_string_append(statustext, options[j]); statustext = g_string_append(statustext, options[j]);
statustext = g_string_append_c(statustext, ' '); statustext = g_string_append_c(statustext, ' ');
} }
statusbar = (GtkStatusbar *) lookup_widget(GTK_WIDGET(wndMain), "statusbar"); statusbar = (GtkStatusbar *)lookup_widget(GTK_WIDGET(wndMain), "statusbar");
context_id = gtk_statusbar_get_context_id(statusbar, "status"); context_id = gtk_statusbar_get_context_id(statusbar, "status");
/* an old message in stack? */ /* an old message in stack? */
@ -402,9 +408,9 @@ int update_statusbar() {
gtk_statusbar_remove(statusbar, context_id, message_id); gtk_statusbar_remove(statusbar, context_id, message_id);
} }
message_id = gtk_statusbar_push(statusbar, context_id, (gchar *) statustext->str); message_id = gtk_statusbar_push(statusbar, context_id, (gchar *)statustext->str);
(void) g_string_free(statustext, TRUE); (void)g_string_free(statustext, TRUE);
return TRUE; return TRUE;
} }
@ -428,11 +434,10 @@ int read_into(int fd) {
} }
output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput"); output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput");
outputbuf = gtk_text_view_get_buffer((GtkTextView *) output); outputbuf = gtk_text_view_get_buffer((GtkTextView *)output);
gtk_text_buffer_get_iter_at_offset(outputbuf, &outputiter, -1); gtk_text_buffer_get_iter_at_offset(outputbuf, &outputiter, -1);
if ((passline = strstr(in_buf, "password: ")) == NULL) { if ((passline = strstr(in_buf, "password: ")) == NULL) {
gtk_text_buffer_insert(outputbuf, &outputiter, in_buf, result); gtk_text_buffer_insert(outputbuf, &outputiter, in_buf, result);
} else { } else {
@ -450,15 +455,13 @@ int read_into(int fd) {
if (end - in_buf - result > 0) { if (end - in_buf - result > 0) {
gtk_text_buffer_insert(outputbuf, &outputiter, end + 1, -1); gtk_text_buffer_insert(outputbuf, &outputiter, end + 1, -1);
} }
} }
if (strstr(in_buf, " finished at ") != NULL) { if (strstr(in_buf, " finished at ") != NULL) {
gtk_text_buffer_insert_with_tags_by_name(outputbuf, &outputiter, "<finished>\n\n", -1, "bold", NULL); gtk_text_buffer_insert_with_tags_by_name(outputbuf, &outputiter, "<finished>\n\n", -1, "bold", NULL);
} }
if (result == BUF_S - 1) /* there might be more available, recurse baby! */ if (result == BUF_S - 1) /* there might be more available, recurse baby! */
return read_into(fd); return read_into(fd);
else else
return TRUE; return TRUE;
@ -515,7 +518,6 @@ static int wait_hydra_output(gpointer data) {
return TRUE; return TRUE;
} }
/* assumes a successfull pipe() won't set the fd's to -1 */ /* assumes a successfull pipe() won't set the fd's to -1 */
static void close_pipe(int *pipe) { static void close_pipe(int *pipe) {
if (-1 != pipe[0]) { if (-1 != pipe[0]) {
@ -535,8 +537,7 @@ static void close_pipe(int *pipe) {
*/ */
int *popen_re_unbuffered(char *command) { int *popen_re_unbuffered(char *command) {
static int p_r[2] = { -1, -1 }, p_e[2] = { static int p_r[2] = {-1, -1}, p_e[2] = {-1, -1};
-1, -1};
static int *pfd = NULL; static int *pfd = NULL;
char *options[128]; char *options[128];
@ -561,7 +562,7 @@ int *popen_re_unbuffered(char *command) {
if ((hydra_pid = fork()) < 0) { if ((hydra_pid = fork()) < 0) {
g_warning("popen_rw_unbuffered: Error forking!"); g_warning("popen_rw_unbuffered: Error forking!");
return NULL; return NULL;
} else if (hydra_pid == 0) { /* child */ } else if (hydra_pid == 0) { /* child */
int k; int k;
if (setpgid(getpid(), getpid()) < 0) if (setpgid(getpid(), getpid()) < 0)
@ -582,7 +583,7 @@ int *popen_re_unbuffered(char *command) {
if (close(p_e[1]) < 0) if (close(p_e[1]) < 0)
g_warning("popen_rw_unbuffered: close(p_e[1]) failed"); g_warning("popen_rw_unbuffered: close(p_e[1]) failed");
(void) hydra_get_options(options); (void)hydra_get_options(options);
execv(HYDRA_BIN, options); execv(HYDRA_BIN, options);
@ -592,7 +593,7 @@ int *popen_re_unbuffered(char *command) {
g_warning("%s", options[k]); g_warning("%s", options[k]);
} }
gtk_main_quit(); gtk_main_quit();
} else { /* parent */ } else { /* parent */
if (close(p_r[1]) < 0) if (close(p_r[1]) < 0)
g_warning("popen_rw_unbuffered: close(p_r[1]) (parent) failed"); g_warning("popen_rw_unbuffered: close(p_r[1]) (parent) failed");
if (close(p_e[1]) < 0) if (close(p_e[1]) < 0)
@ -605,32 +606,25 @@ int *popen_re_unbuffered(char *command) {
return pfd; return pfd;
} }
void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data) { void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data) { gtk_main_quit(); }
gtk_main_quit();
}
void on_about1_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data) { void on_btnStart_clicked(GtkButton *button, gpointer user_data) {
}
void on_btnStart_clicked(GtkButton * button, gpointer user_data) {
int *fd = NULL; int *fd = NULL;
fd = popen_re_unbuffered(NULL); fd = popen_re_unbuffered(NULL);
g_timeout_add(200, wait_hydra_output, fd); g_timeout_add(200, wait_hydra_output, fd);
} }
void on_btnStop_clicked(GtkButton * button, gpointer user_data) { void on_btnStop_clicked(GtkButton *button, gpointer user_data) {
if (hydra_pid != 0) { if (hydra_pid != 0) {
kill(hydra_pid, SIGTERM); kill(hydra_pid, SIGTERM);
hydra_pid = 0; hydra_pid = 0;
} }
} }
void on_wndMain_destroy(GtkObject *object, gpointer user_data) {
void on_wndMain_destroy(GtkObject * object, gpointer user_data) {
if (hydra_pid != 0) { if (hydra_pid != 0) {
kill(hydra_pid, SIGTERM); kill(hydra_pid, SIGTERM);
hydra_pid = 0; hydra_pid = 0;
@ -638,35 +632,31 @@ void on_wndMain_destroy(GtkObject * object, gpointer user_data) {
gtk_main_quit(); gtk_main_quit();
} }
gboolean on_entTargetFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
hydra_select_file((GtkEntry *)widget, "Select target list");
gboolean on_entTargetFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data) {
hydra_select_file((GtkEntry *) widget, "Select target list");
gtk_widget_grab_focus(widget); gtk_widget_grab_focus(widget);
return TRUE; return TRUE;
} }
gboolean on_entUsernameFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
gboolean on_entUsernameFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data) { hydra_select_file((GtkEntry *)widget, "Select username list");
hydra_select_file((GtkEntry *) widget, "Select username list");
gtk_widget_grab_focus(widget); gtk_widget_grab_focus(widget);
return TRUE; return TRUE;
} }
gboolean on_entPassFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
gboolean on_entPassFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data) { hydra_select_file((GtkEntry *)widget, "Select password list");
hydra_select_file((GtkEntry *) widget, "Select password list");
gtk_widget_grab_focus(widget); gtk_widget_grab_focus(widget);
return TRUE; return TRUE;
} }
gboolean on_entColonFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gboolean on_entColonFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
hydra_select_file((GtkEntry *) widget, "Select colon separated user,password list"); hydra_select_file((GtkEntry *)widget, "Select colon separated user,password list");
gtk_widget_grab_focus(widget); gtk_widget_grab_focus(widget);
return TRUE; return TRUE;
} }
void on_btnSave_clicked(GtkButton * button, gpointer user_data) { void on_btnSave_clicked(GtkButton *button, gpointer user_data) {
#ifdef GTK_TYPE_FILE_CHOOSER #ifdef GTK_TYPE_FILE_CHOOSER
GtkWidget *dialog; GtkWidget *dialog;
char *filename; char *filename;
@ -677,20 +667,19 @@ void on_btnSave_clicked(GtkButton * button, gpointer user_data) {
GtkTextIter start; GtkTextIter start;
GtkTextIter end; GtkTextIter end;
dialog = gtk_file_chooser_dialog_new("Save output", (GtkWindow *) wndMain, GTK_FILE_CHOOSER_ACTION_SAVE, dialog = gtk_file_chooser_dialog_new("Save output", (GtkWindow *)wndMain, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput"); output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput");
outputbuf = gtk_text_view_get_buffer((GtkTextView *) output); outputbuf = gtk_text_view_get_buffer((GtkTextView *)output);
gtk_text_buffer_get_start_iter(outputbuf, &start); gtk_text_buffer_get_start_iter(outputbuf, &start);
gtk_text_buffer_get_end_iter(outputbuf, &end); gtk_text_buffer_get_end_iter(outputbuf, &end);
text = gtk_text_buffer_get_text(outputbuf, &start, &end, TRUE); text = gtk_text_buffer_get_text(outputbuf, &start, &end, TRUE);
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644); fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (fd > 0) { if (fd >= 0) {
write(fd, text, strlen(text)); write(fd, text, strlen(text));
close(fd); close(fd);
} }
@ -701,10 +690,11 @@ void on_btnSave_clicked(GtkButton * button, gpointer user_data) {
#endif #endif
} }
void on_chkColon_toggled(GtkToggleButton * togglebutton, gpointer user_data) { void on_chkColon_toggled(GtkToggleButton *togglebutton, gpointer user_data) {
GtkWidget *user, *pass; GtkWidget *user, *pass;
user = lookup_widget(GTK_WIDGET(wndMain), "frmUsername");; user = lookup_widget(GTK_WIDGET(wndMain), "frmUsername");
;
pass = lookup_widget(GTK_WIDGET(wndMain), "frmPass"); pass = lookup_widget(GTK_WIDGET(wndMain), "frmPass");
if (gtk_toggle_button_get_active(togglebutton)) { if (gtk_toggle_button_get_active(togglebutton)) {
@ -716,10 +706,11 @@ void on_chkColon_toggled(GtkToggleButton * togglebutton, gpointer user_data) {
} }
} }
void on_chkDisUser_toggled(GtkToggleButton * togglebutton, gpointer user_data) { void on_chkDisUser_toggled(GtkToggleButton *togglebutton, gpointer user_data) {
GtkWidget *radioUsername1, *radioUsername2, *entUsername, *entUsernameFile; GtkWidget *radioUsername1, *radioUsername2, *entUsername, *entUsernameFile;
radioUsername1 = lookup_widget(GTK_WIDGET(wndMain), "radioUsername1");; radioUsername1 = lookup_widget(GTK_WIDGET(wndMain), "radioUsername1");
;
radioUsername2 = lookup_widget(GTK_WIDGET(wndMain), "radioUsername2"); radioUsername2 = lookup_widget(GTK_WIDGET(wndMain), "radioUsername2");
entUsername = lookup_widget(GTK_WIDGET(wndMain), "entUsername"); entUsername = lookup_widget(GTK_WIDGET(wndMain), "entUsername");
entUsernameFile = lookup_widget(GTK_WIDGET(wndMain), "entUsernameFile"); entUsernameFile = lookup_widget(GTK_WIDGET(wndMain), "entUsernameFile");
@ -737,11 +728,11 @@ void on_chkDisUser_toggled(GtkToggleButton * togglebutton, gpointer user_data) {
} }
} }
void on_btnClear_clicked(GtkButton * button, gpointer user_data) { void on_btnClear_clicked(GtkButton *button, gpointer user_data) {
GtkWidget *output; GtkWidget *output;
GtkTextBuffer *outputbuf; GtkTextBuffer *outputbuf;
output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput"); output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput");
outputbuf = gtk_text_view_get_buffer((GtkTextView *) output); outputbuf = gtk_text_view_get_buffer((GtkTextView *)output);
gtk_text_buffer_set_text(outputbuf, "", -1); gtk_text_buffer_set_text(outputbuf, "", -1);
} }

View file

@ -2,28 +2,28 @@
int update_statusbar(); int update_statusbar();
void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data); void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data); void on_about1_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_btnStart_clicked(GtkButton * button, gpointer user_data); void on_btnStart_clicked(GtkButton *button, gpointer user_data);
void on_wndMain_destroy(GtkObject * object, gpointer user_data); void on_wndMain_destroy(GtkObject *object, gpointer user_data);
void on_btnStop_clicked(GtkButton * button, gpointer user_data); void on_btnStop_clicked(GtkButton *button, gpointer user_data);
gboolean on_entTargetFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data); gboolean on_entTargetFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
gboolean on_entUsernameFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data); gboolean on_entUsernameFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
gboolean on_entPassFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data); gboolean on_entPassFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
void on_btnSave_clicked(GtkButton * button, gpointer user_data); void on_btnSave_clicked(GtkButton *button, gpointer user_data);
gboolean on_entColonFile_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data); gboolean on_entColonFile_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
void on_chkColon_toggled(GtkToggleButton * togglebutton, gpointer user_data); void on_chkColon_toggled(GtkToggleButton *togglebutton, gpointer user_data);
void on_btnClear_clicked(GtkButton * button, gpointer user_data); void on_btnClear_clicked(GtkButton *button, gpointer user_data);
void on_chkDisUser_toggled(GtkToggleButton * togglebutton, gpointer user_data); void on_chkDisUser_toggled(GtkToggleButton *togglebutton, gpointer user_data);

View file

@ -7,13 +7,13 @@
#include <config.h> #include <config.h>
#endif #endif
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -22,12 +22,9 @@
#include "interface.h" #include "interface.h"
#include "support.h" #include "support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \ #define GLADE_HOOKUP_OBJECT(component, widget, name) g_object_set_data_full(G_OBJECT(component), name, gtk_widget_ref(widget), (GDestroyNotify)gtk_widget_unref)
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ #define GLADE_HOOKUP_OBJECT_NO_REF(component, widget, name) g_object_set_data(G_OBJECT(component), name, widget)
g_object_set_data (G_OBJECT (component), name, widget)
GtkWidget *create_wndMain(void) { GtkWidget *create_wndMain(void) {
GtkWidget *wndMain; GtkWidget *wndMain;
@ -171,6 +168,9 @@ GtkWidget *create_wndMain(void) {
GtkWidget *btnClear; GtkWidget *btnClear;
GtkWidget *label4; GtkWidget *label4;
GtkWidget *statusbar; GtkWidget *statusbar;
GtkWidget *lblSMB2;
GtkWidget *entSMB2Workgroup;
GtkWidget *fraSMB2;
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
GtkTooltips *tooltips; GtkTooltips *tooltips;
@ -221,7 +221,7 @@ GtkWidget *create_wndMain(void) {
g_object_set_data(G_OBJECT(GTK_COMBO(cmbProtocol)->popwin), "GladeParentKey", cmbProtocol); g_object_set_data(G_OBJECT(GTK_COMBO(cmbProtocol)->popwin), "GladeParentKey", cmbProtocol);
gtk_widget_set_name(cmbProtocol, "cmbProtocol"); gtk_widget_set_name(cmbProtocol, "cmbProtocol");
gtk_widget_show(cmbProtocol); gtk_widget_show(cmbProtocol);
gtk_table_attach(GTK_TABLE(table8), cmbProtocol, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), cmbProtocol, 1, 2, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "adam6500"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "adam6500");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "afp"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "afp");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "asterisk"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "asterisk");
@ -248,6 +248,8 @@ GtkWidget *create_wndMain(void) {
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-crammd5"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-crammd5");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-digestmd5"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-digestmd5");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "memcached");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mongodb");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mssql"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mssql");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mysql"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mysql");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ncp"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ncp");
@ -271,6 +273,7 @@ GtkWidget *create_wndMain(void) {
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "sapr3"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "sapr3");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "sip"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "sip");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "smb"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "smb");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "smb2");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "smtp"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "smtp");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "snmp"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "snmp");
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "socks5"); cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "socks5");
@ -293,53 +296,52 @@ GtkWidget *create_wndMain(void) {
label7 = gtk_label_new("Protocol"); label7 = gtk_label_new("Protocol");
gtk_widget_set_name(label7, "label7"); gtk_widget_set_name(label7, "label7");
gtk_widget_show(label7); gtk_widget_show(label7);
gtk_table_attach(GTK_TABLE(table8), label7, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), label7, 0, 1, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5);
spnPort_adj = gtk_adjustment_new(0, 0, 65535, 1, 10, 0); spnPort_adj = gtk_adjustment_new(0, 0, 65535, 1, 10, 0);
spnPort = gtk_spin_button_new(GTK_ADJUSTMENT(spnPort_adj), 1, 0); spnPort = gtk_spin_button_new(GTK_ADJUSTMENT(spnPort_adj), 1, 0);
gtk_widget_set_name(spnPort, "spnPort"); gtk_widget_set_name(spnPort, "spnPort");
gtk_widget_show(spnPort); gtk_widget_show(spnPort);
gtk_table_attach(GTK_TABLE(table8), spnPort, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), spnPort, 1, 2, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, spnPort, "select the port on which the daemon you want to brute force runs, 0 means default", NULL); gtk_tooltips_set_tip(tooltips, spnPort, "select the port on which the daemon you want to brute force runs, 0 means default", NULL);
label6 = gtk_label_new("Port"); label6 = gtk_label_new("Port");
gtk_widget_set_name(label6, "label6"); gtk_widget_set_name(label6, "label6");
gtk_widget_show(label6); gtk_widget_show(label6);
gtk_table_attach(GTK_TABLE(table8), label6, 0, 1, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), label6, 0, 1, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5);
chkIPV6 = gtk_check_button_new_with_mnemonic("Prefer IPV6"); chkIPV6 = gtk_check_button_new_with_mnemonic("Prefer IPV6");
gtk_widget_set_name(chkIPV6, "chkIPV6"); gtk_widget_set_name(chkIPV6, "chkIPV6");
gtk_widget_show(chkIPV6); gtk_widget_show(chkIPV6);
gtk_table_attach(GTK_TABLE(table8), chkIPV6, 0, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), chkIPV6, 0, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkIPV6, "Enable to use IPV6", NULL); gtk_tooltips_set_tip(tooltips, chkIPV6, "Enable to use IPV6", NULL);
radioTarget2 = gtk_radio_button_new_with_mnemonic(NULL, "Target List"); radioTarget2 = gtk_radio_button_new_with_mnemonic(NULL, "Target List");
gtk_widget_set_name(radioTarget2, "radioTarget2"); gtk_widget_set_name(radioTarget2, "radioTarget2");
gtk_widget_show(radioTarget2); gtk_widget_show(radioTarget2);
gtk_table_attach(GTK_TABLE(table8), radioTarget2, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), radioTarget2, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioTarget2), radioTarget2_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioTarget2), radioTarget2_group);
radioTarget2_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioTarget2)); radioTarget2_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioTarget2));
entTargetFile = gtk_entry_new(); entTargetFile = gtk_entry_new();
gtk_widget_set_name(entTargetFile, "entTargetFile"); gtk_widget_set_name(entTargetFile, "entTargetFile");
gtk_widget_show(entTargetFile); gtk_widget_show(entTargetFile);
gtk_table_attach(GTK_TABLE(table8), entTargetFile, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), entTargetFile, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entTargetFile, "A file which contains the targets to attack. One entry per line. IP\naddresses and/or DNS names.", NULL); gtk_tooltips_set_tip(tooltips, entTargetFile, "A file which contains the targets to attack. One entry per line. IP\naddresses and/or DNS names.", NULL);
entTarget = gtk_entry_new(); entTarget = gtk_entry_new();
gtk_widget_set_name(entTarget, "entTarget"); gtk_widget_set_name(entTarget, "entTarget");
gtk_widget_show(entTarget); gtk_widget_show(entTarget);
gtk_table_attach(GTK_TABLE(table8), entTarget, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), entTarget, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entTarget, "The target to attack - DNS name or IP address", NULL); gtk_tooltips_set_tip(tooltips, entTarget, "The target to attack - DNS name or IP address", NULL);
gtk_entry_set_text(GTK_ENTRY(entTarget), "127.0.0.1"); gtk_entry_set_text(GTK_ENTRY(entTarget), "127.0.0.1");
radioTarget1 = gtk_radio_button_new_with_mnemonic(NULL, "Single Target"); radioTarget1 = gtk_radio_button_new_with_mnemonic(NULL, "Single Target");
gtk_widget_set_name(radioTarget1, "radioTarget1"); gtk_widget_set_name(radioTarget1, "radioTarget1");
gtk_widget_show(radioTarget1); gtk_widget_show(radioTarget1);
gtk_table_attach(GTK_TABLE(table8), radioTarget1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table8), radioTarget1, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioTarget1), radioTarget2_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioTarget1), radioTarget2_group);
radioTarget2_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioTarget1)); radioTarget2_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioTarget1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioTarget1), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioTarget1), TRUE);
@ -362,50 +364,44 @@ GtkWidget *create_wndMain(void) {
chkVerbose = gtk_check_button_new_with_mnemonic("Be Verbose"); chkVerbose = gtk_check_button_new_with_mnemonic("Be Verbose");
gtk_widget_set_name(chkVerbose, "chkVerbose"); gtk_widget_set_name(chkVerbose, "chkVerbose");
gtk_widget_show(chkVerbose); gtk_widget_show(chkVerbose);
gtk_table_attach(GTK_TABLE(table9), chkVerbose, 2, 3, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table9), chkVerbose, 2, 3, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkVerbose, "be verbose", NULL); gtk_tooltips_set_tip(tooltips, chkVerbose, "be verbose", NULL);
chkDebug = gtk_check_button_new_with_mnemonic("Debug"); chkDebug = gtk_check_button_new_with_mnemonic("Debug");
gtk_widget_set_name(chkDebug, "chkDebug"); gtk_widget_set_name(chkDebug, "chkDebug");
gtk_widget_show(chkDebug); gtk_widget_show(chkDebug);
gtk_table_attach(GTK_TABLE(table9), chkDebug, 2, 3, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table9), chkDebug, 2, 3, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkDebug, "Enable debug mode", NULL); gtk_tooltips_set_tip(tooltips, chkDebug, "Enable debug mode", NULL);
chkAttempts = gtk_check_button_new_with_mnemonic("Show Attempts"); chkAttempts = gtk_check_button_new_with_mnemonic("Show Attempts");
gtk_widget_set_name(chkAttempts, "chkAttempts"); gtk_widget_set_name(chkAttempts, "chkAttempts");
gtk_widget_show(chkAttempts); gtk_widget_show(chkAttempts);
gtk_table_attach(GTK_TABLE(table9), chkAttempts, 0, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table9), chkAttempts, 0, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkAttempts, "Show attempts", NULL); gtk_tooltips_set_tip(tooltips, chkAttempts, "Show attempts", NULL);
chkSSL = gtk_check_button_new_with_mnemonic("Use SSL"); chkSSL = gtk_check_button_new_with_mnemonic("Use SSL");
gtk_widget_set_name(chkSSL, "chkSSL"); gtk_widget_set_name(chkSSL, "chkSSL");
gtk_widget_show(chkSSL); gtk_widget_show(chkSSL);
gtk_table_attach(GTK_TABLE(table9), chkSSL, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table9), chkSSL, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkSSL, "Enable to use SSL (the target must have SSL enabled!)", NULL); gtk_tooltips_set_tip(tooltips, chkSSL, "Enable to use SSL (the target must have SSL enabled!)", NULL);
chkServiceDetails = gtk_check_button_new_with_mnemonic ("Service Module Usage Details"); chkServiceDetails = gtk_check_button_new_with_mnemonic("Service Module Usage Details");
gtk_widget_set_name (chkServiceDetails, "chkServiceDetails"); gtk_widget_set_name(chkServiceDetails, "chkServiceDetails");
gtk_widget_show (chkServiceDetails); gtk_widget_show(chkServiceDetails);
gtk_table_attach (GTK_TABLE (table9), chkServiceDetails, 2, 3, 2, 3, gtk_table_attach(GTK_TABLE(table9), chkServiceDetails, 2, 3, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, chkServiceDetails, "Service Module Usage Details", NULL);
(GtkAttachOptions) (GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkServiceDetails, "Service Module Usage Details", NULL);
chkCompleteHelp = gtk_check_button_new_with_mnemonic ("COMPLETE HELP"); chkCompleteHelp = gtk_check_button_new_with_mnemonic("COMPLETE HELP");
gtk_widget_set_name (chkCompleteHelp, "chkCompleteHelp"); gtk_widget_set_name(chkCompleteHelp, "chkCompleteHelp");
gtk_widget_show (chkCompleteHelp); gtk_widget_show(chkCompleteHelp);
gtk_table_attach (GTK_TABLE (table9), chkCompleteHelp, 0, 2, 2, 3, gtk_table_attach(GTK_TABLE(table9), chkCompleteHelp, 0, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, chkCompleteHelp, "Complete Help", NULL);
(GtkAttachOptions) (GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkCompleteHelp, "Complete Help", NULL);
chkOldSSL = gtk_check_button_new_with_mnemonic ("Use old SSL"); chkOldSSL = gtk_check_button_new_with_mnemonic("Use old SSL");
gtk_widget_set_name (chkOldSSL, "chkOldSSL"); gtk_widget_set_name(chkOldSSL, "chkOldSSL");
gtk_widget_show (chkOldSSL); gtk_widget_show(chkOldSSL);
gtk_table_attach (GTK_TABLE (table9), chkOldSSL, 1, 2, 0, 1, gtk_table_attach(GTK_TABLE(table9), chkOldSSL, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, chkOldSSL, "Enable to use old SSL (the target must have SSL enabled!)", NULL);
(GtkAttachOptions) (GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkOldSSL, "Enable to use old SSL (the target must have SSL enabled!)", NULL);
label29 = gtk_label_new("Output Options"); label29 = gtk_label_new("Output Options");
gtk_widget_set_name(label29, "label29"); gtk_widget_set_name(label29, "label29");
@ -435,20 +431,20 @@ GtkWidget *create_wndMain(void) {
entUsernameFile = gtk_entry_new(); entUsernameFile = gtk_entry_new();
gtk_widget_set_name(entUsernameFile, "entUsernameFile"); gtk_widget_set_name(entUsernameFile, "entUsernameFile");
gtk_widget_show(entUsernameFile); gtk_widget_show(entUsernameFile);
gtk_table_attach(GTK_TABLE(table2), entUsernameFile, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table2), entUsernameFile, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_tooltips_set_tip(tooltips, entUsernameFile, "File with user logins, one entry per line", NULL); gtk_tooltips_set_tip(tooltips, entUsernameFile, "File with user logins, one entry per line", NULL);
entUsername = gtk_entry_new(); entUsername = gtk_entry_new();
gtk_widget_set_name(entUsername, "entUsername"); gtk_widget_set_name(entUsername, "entUsername");
gtk_widget_show(entUsername); gtk_widget_show(entUsername);
gtk_table_attach(GTK_TABLE(table2), entUsername, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table2), entUsername, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_tooltips_set_tip(tooltips, entUsername, "The login to use", NULL); gtk_tooltips_set_tip(tooltips, entUsername, "The login to use", NULL);
gtk_entry_set_text(GTK_ENTRY(entUsername), "yourname"); gtk_entry_set_text(GTK_ENTRY(entUsername), "yourname");
radioUsername1 = gtk_radio_button_new_with_mnemonic(NULL, "Username"); radioUsername1 = gtk_radio_button_new_with_mnemonic(NULL, "Username");
gtk_widget_set_name(radioUsername1, "radioUsername1"); gtk_widget_set_name(radioUsername1, "radioUsername1");
gtk_widget_show(radioUsername1); gtk_widget_show(radioUsername1);
gtk_table_attach(GTK_TABLE(table2), radioUsername1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table2), radioUsername1, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioUsername1), radioUsername1_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioUsername1), radioUsername1_group);
radioUsername1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioUsername1)); radioUsername1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioUsername1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioUsername1), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioUsername1), TRUE);
@ -456,20 +452,20 @@ GtkWidget *create_wndMain(void) {
radioUsername2 = gtk_radio_button_new_with_mnemonic(NULL, "Username List"); radioUsername2 = gtk_radio_button_new_with_mnemonic(NULL, "Username List");
gtk_widget_set_name(radioUsername2, "radioUsername2"); gtk_widget_set_name(radioUsername2, "radioUsername2");
gtk_widget_show(radioUsername2); gtk_widget_show(radioUsername2);
gtk_table_attach(GTK_TABLE(table2), radioUsername2, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table2), radioUsername2, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioUsername2), radioUsername1_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioUsername2), radioUsername1_group);
radioUsername1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioUsername2)); radioUsername1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioUsername2));
chkUsernameLoop = gtk_check_button_new_with_mnemonic("Loop around users"); chkUsernameLoop = gtk_check_button_new_with_mnemonic("Loop around users");
gtk_widget_set_name(chkUsernameLoop, "chkUsernameLoop"); gtk_widget_set_name(chkUsernameLoop, "chkUsernameLoop");
gtk_widget_show(chkUsernameLoop); gtk_widget_show(chkUsernameLoop);
gtk_table_attach(GTK_TABLE(table2), chkUsernameLoop, 0, 1, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table2), chkUsernameLoop, 0, 1, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkUsernameLoop, "Enable this option to loop around users not passwords", NULL); gtk_tooltips_set_tip(tooltips, chkUsernameLoop, "Enable this option to loop around users not passwords", NULL);
chkDisUser = gtk_check_button_new_with_mnemonic("Protocol does not require usernames"); chkDisUser = gtk_check_button_new_with_mnemonic("Protocol does not require usernames");
gtk_widget_set_name(chkDisUser, "chkDisUser"); gtk_widget_set_name(chkDisUser, "chkDisUser");
gtk_widget_show(chkDisUser); gtk_widget_show(chkDisUser);
gtk_table_attach(GTK_TABLE (table2), chkDisUser, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table2), chkDisUser, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkDisUser, "Protocols like Cisco, Cisco enable, redis, Oracle listener, SNMP, S7-300, VNC etc. are not using usernames", NULL); gtk_tooltips_set_tip(tooltips, chkDisUser, "Protocols like Cisco, Cisco enable, redis, Oracle listener, SNMP, S7-300, VNC etc. are not using usernames", NULL);
label8 = gtk_label_new("Username"); label8 = gtk_label_new("Username");
@ -482,7 +478,7 @@ GtkWidget *create_wndMain(void) {
gtk_widget_show(frmPass); gtk_widget_show(frmPass);
gtk_box_pack_start(GTK_BOX(vbox2), frmPass, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox2), frmPass, TRUE, TRUE, 0);
table3 = gtk_table_new (3, 2, FALSE); table3 = gtk_table_new(3, 2, FALSE);
gtk_widget_set_name(table3, "table3"); gtk_widget_set_name(table3, "table3");
gtk_widget_show(table3); gtk_widget_show(table3);
gtk_container_add(GTK_CONTAINER(frmPass), table3); gtk_container_add(GTK_CONTAINER(frmPass), table3);
@ -490,20 +486,20 @@ GtkWidget *create_wndMain(void) {
entPassFile = gtk_entry_new(); entPassFile = gtk_entry_new();
gtk_widget_set_name(entPassFile, "entPassFile"); gtk_widget_set_name(entPassFile, "entPassFile");
gtk_widget_show(entPassFile); gtk_widget_show(entPassFile);
gtk_table_attach(GTK_TABLE(table3), entPassFile, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table3), entPassFile, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_tooltips_set_tip(tooltips, entPassFile, "File with passwords to try, one entry per line", NULL); gtk_tooltips_set_tip(tooltips, entPassFile, "File with passwords to try, one entry per line", NULL);
entPass = gtk_entry_new(); entPass = gtk_entry_new();
gtk_widget_set_name(entPass, "entPass"); gtk_widget_set_name(entPass, "entPass");
gtk_widget_show(entPass); gtk_widget_show(entPass);
gtk_table_attach(GTK_TABLE(table3), entPass, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table3), entPass, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_tooltips_set_tip(tooltips, entPass, "The password to try", NULL); gtk_tooltips_set_tip(tooltips, entPass, "The password to try", NULL);
gtk_entry_set_text(GTK_ENTRY(entPass), "yourpass"); gtk_entry_set_text(GTK_ENTRY(entPass), "yourpass");
radioPass1 = gtk_radio_button_new_with_mnemonic(NULL, "Password"); radioPass1 = gtk_radio_button_new_with_mnemonic(NULL, "Password");
gtk_widget_set_name(radioPass1, "radioPass1"); gtk_widget_set_name(radioPass1, "radioPass1");
gtk_widget_show(radioPass1); gtk_widget_show(radioPass1);
gtk_table_attach(GTK_TABLE(table3), radioPass1, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table3), radioPass1, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioPass1), radioPass1_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioPass1), radioPass1_group);
radioPass1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioPass1)); radioPass1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioPass1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioPass1), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radioPass1), TRUE);
@ -511,26 +507,22 @@ GtkWidget *create_wndMain(void) {
radioPass2 = gtk_radio_button_new_with_mnemonic(NULL, "Password List"); radioPass2 = gtk_radio_button_new_with_mnemonic(NULL, "Password List");
gtk_widget_set_name(radioPass2, "radioPass2"); gtk_widget_set_name(radioPass2, "radioPass2");
gtk_widget_show(radioPass2); gtk_widget_show(radioPass2);
gtk_table_attach(GTK_TABLE(table3), radioPass2, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_table_attach(GTK_TABLE(table3), radioPass2, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioPass2), radioPass1_group); gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioPass2), radioPass1_group);
radioPass1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioPass2)); radioPass1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioPass2));
radioGenerate = gtk_radio_button_new_with_mnemonic (NULL, "Generate"); radioGenerate = gtk_radio_button_new_with_mnemonic(NULL, "Generate");
gtk_widget_set_name (radioGenerate, "radioGenerate"); gtk_widget_set_name(radioGenerate, "radioGenerate");
gtk_widget_show (radioGenerate); gtk_widget_show(radioGenerate);
gtk_table_attach (GTK_TABLE (table3), radioGenerate, 0, 1, 2, 3, gtk_table_attach(GTK_TABLE(table3), radioGenerate, 0, 1, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_radio_button_set_group(GTK_RADIO_BUTTON(radioGenerate), radioPass1_group);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); radioPass1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioGenerate));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioGenerate), radioPass1_group);
radioPass1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioGenerate));
entGeneration = gtk_entry_new (); entGeneration = gtk_entry_new();
gtk_widget_set_name (entGeneration, "entGeneration"); gtk_widget_set_name(entGeneration, "entGeneration");
gtk_widget_show (entGeneration); gtk_widget_show(entGeneration);
gtk_table_attach (GTK_TABLE (table3), entGeneration, 1, 2, 2, 3, gtk_table_attach(GTK_TABLE(table3), entGeneration, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, entGeneration, "Generate passwords", NULL);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), 0, 0); gtk_entry_set_text(GTK_ENTRY(entGeneration), "1:1:a");
gtk_tooltips_set_tip (tooltips, entGeneration, "Generate passwords", NULL);
gtk_entry_set_text (GTK_ENTRY (entGeneration), "1:1:a");
labelpass = gtk_label_new("Password"); labelpass = gtk_label_new("Password");
gtk_widget_set_name(labelpass, "labelpass"); gtk_widget_set_name(labelpass, "labelpass");
@ -550,13 +542,13 @@ GtkWidget *create_wndMain(void) {
chkColon = gtk_check_button_new_with_mnemonic("Use Colon separated file"); chkColon = gtk_check_button_new_with_mnemonic("Use Colon separated file");
gtk_widget_set_name(chkColon, "chkColon"); gtk_widget_set_name(chkColon, "chkColon");
gtk_widget_show(chkColon); gtk_widget_show(chkColon);
gtk_table_attach(GTK_TABLE(table5), chkColon, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table5), chkColon, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkColon, "Enable this option to use a colon file for login/password attempts", NULL); gtk_tooltips_set_tip(tooltips, chkColon, "Enable this option to use a colon file for login/password attempts", NULL);
entColonFile = gtk_entry_new(); entColonFile = gtk_entry_new();
gtk_widget_set_name(entColonFile, "entColonFile"); gtk_widget_set_name(entColonFile, "entColonFile");
gtk_widget_show(entColonFile); gtk_widget_show(entColonFile);
gtk_table_attach(GTK_TABLE(table5), entColonFile, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table5), entColonFile, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entColonFile, "The colon file to use, each line has to be structured like \"mylogin:mypass\"", NULL); gtk_tooltips_set_tip(tooltips, entColonFile, "The colon file to use, each line has to be structured like \"mylogin:mypass\"", NULL);
label20 = gtk_label_new("Colon separated file"); label20 = gtk_label_new("Colon separated file");
@ -572,21 +564,21 @@ GtkWidget *create_wndMain(void) {
chkPassLogin = gtk_check_button_new_with_mnemonic("Try login as password"); chkPassLogin = gtk_check_button_new_with_mnemonic("Try login as password");
gtk_widget_set_name(chkPassLogin, "chkPassLogin"); gtk_widget_set_name(chkPassLogin, "chkPassLogin");
gtk_widget_show(chkPassLogin); gtk_widget_show(chkPassLogin);
gtk_table_attach(GTK_TABLE(table6), chkPassLogin, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table6), chkPassLogin, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkPassLogin, "Enable this option to try the login as password, in addition to the password/file", NULL); gtk_tooltips_set_tip(tooltips, chkPassLogin, "Enable this option to try the login as password, in addition to the password/file", NULL);
chkPassNull = gtk_check_button_new_with_mnemonic("Try empty password"); chkPassNull = gtk_check_button_new_with_mnemonic("Try empty password");
gtk_widget_set_name(chkPassNull, "chkPassNull"); gtk_widget_set_name(chkPassNull, "chkPassNull");
gtk_widget_show(chkPassNull); gtk_widget_show(chkPassNull);
gtk_table_attach(GTK_TABLE(table6), chkPassNull, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table6), chkPassNull, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkPassNull, "Enable this option to try an empty password, in addition to the password/file", NULL); gtk_tooltips_set_tip(tooltips, chkPassNull, "Enable this option to try an empty password, in addition to the password/file", NULL);
chkPassReverse = gtk_check_button_new_with_mnemonic ("Try reversed login"); chkPassReverse = gtk_check_button_new_with_mnemonic("Try reversed login");
gtk_widget_set_name (chkPassReverse, "chkPassReverse"); gtk_widget_set_name(chkPassReverse, "chkPassReverse");
gtk_widget_show (chkPassReverse); gtk_widget_show(chkPassReverse);
gtk_table_attach (GTK_TABLE (table6), chkPassReverse, 2, 3, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table6), chkPassReverse, 2, 3, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkPassReverse, "Enable this option to try an reverse password, in addition to the password/file", NULL); gtk_tooltips_set_tip(tooltips, chkPassReverse, "Enable this option to try an reverse password, in addition to the password/file", NULL);
label2 = gtk_label_new("Passwords"); label2 = gtk_label_new("Passwords");
gtk_widget_set_name(label2, "label2"); gtk_widget_set_name(label2, "label2");
gtk_widget_show(label2); gtk_widget_show(label2);
@ -600,7 +592,7 @@ GtkWidget *create_wndMain(void) {
frame9 = gtk_frame_new(NULL); frame9 = gtk_frame_new(NULL);
gtk_widget_set_name(frame9, "frame9"); gtk_widget_set_name(frame9, "frame9");
gtk_widget_show(frame9); gtk_widget_show(frame9);
gtk_table_attach(GTK_TABLE(table4), frame9, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0); gtk_table_attach(GTK_TABLE(table4), frame9, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
table7 = gtk_table_new(5, 2, FALSE); table7 = gtk_table_new(5, 2, FALSE);
gtk_widget_set_name(table7, "table7"); gtk_widget_set_name(table7, "table7");
@ -610,58 +602,58 @@ GtkWidget *create_wndMain(void) {
label22 = gtk_label_new("Proxy "); label22 = gtk_label_new("Proxy ");
gtk_widget_set_name(label22, "label22"); gtk_widget_set_name(label22, "label22");
gtk_widget_show(label22); gtk_widget_show(label22);
gtk_table_attach(GTK_TABLE(table7), label22, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), label22, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label22), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label22), 0, 0.5);
entHTTPProxy = gtk_entry_new(); entHTTPProxy = gtk_entry_new();
gtk_widget_set_name(entHTTPProxy, "entHTTPProxy"); gtk_widget_set_name(entHTTPProxy, "entHTTPProxy");
gtk_widget_show(entHTTPProxy); gtk_widget_show(entHTTPProxy);
gtk_table_attach(GTK_TABLE(table7), entHTTPProxy, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), entHTTPProxy, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entHTTPProxy, "The address of the proxy. Syntax: \"http://123.45.67.89:8080\"", NULL); gtk_tooltips_set_tip(tooltips, entHTTPProxy, "The address of the proxy. Syntax: \"http://123.45.67.89:8080\"", NULL);
gtk_entry_set_text(GTK_ENTRY(entHTTPProxy), "http://127.0.0.1:8080"); gtk_entry_set_text(GTK_ENTRY(entHTTPProxy), "http://127.0.0.1:8080");
chkProxyAuth = gtk_check_button_new_with_mnemonic("Proxy needs authentication"); chkProxyAuth = gtk_check_button_new_with_mnemonic("Proxy needs authentication");
gtk_widget_set_name(chkProxyAuth, "chkProxyAuth"); gtk_widget_set_name(chkProxyAuth, "chkProxyAuth");
gtk_widget_show(chkProxyAuth); gtk_widget_show(chkProxyAuth);
gtk_table_attach(GTK_TABLE(table7), chkProxyAuth, 0, 1, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), chkProxyAuth, 0, 1, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkProxyAuth, "Enable this if the proxy requires authenticatio", NULL); gtk_tooltips_set_tip(tooltips, chkProxyAuth, "Enable this if the proxy requires authenticatio", NULL);
label23 = gtk_label_new("Username"); label23 = gtk_label_new("Username");
gtk_widget_set_name(label23, "label23"); gtk_widget_set_name(label23, "label23");
gtk_widget_show(label23); gtk_widget_show(label23);
gtk_table_attach(GTK_TABLE(table7), label23, 0, 1, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), label23, 0, 1, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label23), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label23), 0, 0.5);
entProxyUser = gtk_entry_new(); entProxyUser = gtk_entry_new();
gtk_widget_set_name(entProxyUser, "entProxyUser"); gtk_widget_set_name(entProxyUser, "entProxyUser");
gtk_widget_show(entProxyUser); gtk_widget_show(entProxyUser);
gtk_table_attach(GTK_TABLE(table7), entProxyUser, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), entProxyUser, 1, 2, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entProxyUser, "The user name for proxy authentication", NULL); gtk_tooltips_set_tip(tooltips, entProxyUser, "The user name for proxy authentication", NULL);
gtk_entry_set_text(GTK_ENTRY(entProxyUser), "yourname"); gtk_entry_set_text(GTK_ENTRY(entProxyUser), "yourname");
label24 = gtk_label_new("Password"); label24 = gtk_label_new("Password");
gtk_widget_set_name(label24, "label24"); gtk_widget_set_name(label24, "label24");
gtk_widget_show(label24); gtk_widget_show(label24);
gtk_table_attach(GTK_TABLE(table7), label24, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), label24, 0, 1, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label24), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label24), 0, 0.5);
entProxyPass = gtk_entry_new(); entProxyPass = gtk_entry_new();
gtk_widget_set_name(entProxyPass, "entProxyPass"); gtk_widget_set_name(entProxyPass, "entProxyPass");
gtk_widget_show(entProxyPass); gtk_widget_show(entProxyPass);
gtk_table_attach(GTK_TABLE(table7), entProxyPass, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table7), entProxyPass, 1, 2, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, entProxyPass, "The password for proxy authentication", NULL); gtk_tooltips_set_tip(tooltips, entProxyPass, "The password for proxy authentication", NULL);
gtk_entry_set_text(GTK_ENTRY(entProxyPass), "yourpass"); gtk_entry_set_text(GTK_ENTRY(entProxyPass), "yourpass");
label26 = gtk_label_new(""); label26 = gtk_label_new("");
gtk_widget_set_name(label26, "label26"); gtk_widget_set_name(label26, "label26");
gtk_widget_show(label26); gtk_widget_show(label26);
gtk_table_attach(GTK_TABLE(table7), label26, 1, 2, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_table_attach(GTK_TABLE(table7), label26, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label26), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label26), 0, 0.5);
hbox3 = gtk_hbox_new(FALSE, 0); hbox3 = gtk_hbox_new(FALSE, 0);
gtk_widget_set_name(hbox3, "hbox3"); gtk_widget_set_name(hbox3, "hbox3");
gtk_widget_show(hbox3); gtk_widget_show(hbox3);
gtk_table_attach(GTK_TABLE(table7), hbox3, 0, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_table_attach(GTK_TABLE(table7), hbox3, 0, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
radioProxy = gtk_radio_button_new_with_mnemonic(NULL, "No Proxy"); radioProxy = gtk_radio_button_new_with_mnemonic(NULL, "No Proxy");
gtk_widget_set_name(radioProxy, "radioProxy"); gtk_widget_set_name(radioProxy, "radioProxy");
@ -695,7 +687,7 @@ GtkWidget *create_wndMain(void) {
frame13 = gtk_frame_new(NULL); frame13 = gtk_frame_new(NULL);
gtk_widget_set_name(frame13, "frame13"); gtk_widget_set_name(frame13, "frame13");
gtk_widget_show(frame13); gtk_widget_show(frame13);
gtk_table_attach(GTK_TABLE(table4), frame13, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_table_attach(GTK_TABLE(table4), frame13, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
table10 = gtk_table_new(5, 2, FALSE); table10 = gtk_table_new(5, 2, FALSE);
gtk_widget_set_name(table10, "table10"); gtk_widget_set_name(table10, "table10");
@ -705,50 +697,46 @@ GtkWidget *create_wndMain(void) {
chkExitf = gtk_check_button_new_with_mnemonic("Exit after first found pair (per host)"); chkExitf = gtk_check_button_new_with_mnemonic("Exit after first found pair (per host)");
gtk_widget_set_name(chkExitf, "chkExitf"); gtk_widget_set_name(chkExitf, "chkExitf");
gtk_widget_show(chkExitf); gtk_widget_show(chkExitf);
gtk_table_attach(GTK_TABLE(table10), chkExitf, 0, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table10), chkExitf, 0, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, chkExitf, "Enable this to stop all attacking processes once a valid login/password pair is found (per host)", NULL); gtk_tooltips_set_tip(tooltips, chkExitf, "Enable this to stop all attacking processes once a valid login/password pair is found (per host)", NULL);
spnTimeout_adj = gtk_adjustment_new(30, 0, 295, 1, 10, 0); spnTimeout_adj = gtk_adjustment_new(30, 0, 295, 1, 10, 0);
spnTimeout = gtk_spin_button_new(GTK_ADJUSTMENT(spnTimeout_adj), 1, 0); spnTimeout = gtk_spin_button_new(GTK_ADJUSTMENT(spnTimeout_adj), 1, 0);
gtk_widget_set_name(spnTimeout, "spnTimeout"); gtk_widget_set_name(spnTimeout, "spnTimeout");
gtk_widget_show(spnTimeout); gtk_widget_show(spnTimeout);
gtk_table_attach(GTK_TABLE(table10), spnTimeout, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table10), spnTimeout, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, spnTimeout, "The maximum timeout an attack process is waiting for a response from the target", NULL); gtk_tooltips_set_tip(tooltips, spnTimeout, "The maximum timeout an attack process is waiting for a response from the target", NULL);
spnTasks_adj = gtk_adjustment_new(16, 0, 128, 1, 10, 0); spnTasks_adj = gtk_adjustment_new(16, 0, 128, 1, 10, 0);
spnTasks = gtk_spin_button_new(GTK_ADJUSTMENT(spnTasks_adj), 1, 0); spnTasks = gtk_spin_button_new(GTK_ADJUSTMENT(spnTasks_adj), 1, 0);
gtk_widget_set_name(spnTasks, "spnTasks"); gtk_widget_set_name(spnTasks, "spnTasks");
gtk_widget_show(spnTasks); gtk_widget_show(spnTasks);
gtk_table_attach(GTK_TABLE(table10), spnTasks, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table10), spnTasks, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip(tooltips, spnTasks, "The number of attack tasks to run in parallel. The more the faster, the most: computer lockup :-) 16-64 is a good choice", NULL); gtk_tooltips_set_tip(tooltips, spnTasks, "The number of attack tasks to run in parallel. The more the faster, the most: computer lockup :-) 16-64 is a good choice", NULL);
label32 = gtk_label_new("Timeout"); label32 = gtk_label_new("Timeout");
gtk_widget_set_name(label32, "label32"); gtk_widget_set_name(label32, "label32");
gtk_widget_show(label32); gtk_widget_show(label32);
gtk_table_attach(GTK_TABLE(table10), label32, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table10), label32, 0, 1, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label32), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label32), 0, 0.5);
label31 = gtk_label_new("Number of Tasks"); label31 = gtk_label_new("Number of Tasks");
gtk_widget_set_name(label31, "label31"); gtk_widget_set_name(label31, "label31");
gtk_widget_show(label31); gtk_widget_show(label31);
gtk_table_attach(GTK_TABLE(table10), label31, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions) (GTK_EXPAND), 0, 0); gtk_table_attach(GTK_TABLE(table10), label31, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label31), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label31), 0, 0.5);
chkExitF = gtk_check_button_new_with_mnemonic ("Exit after first found pair (global)"); chkExitF = gtk_check_button_new_with_mnemonic("Exit after first found pair (global)");
gtk_widget_set_name (chkExitF, "chkExitF"); gtk_widget_set_name(chkExitF, "chkExitF");
gtk_widget_show (chkExitF); gtk_widget_show(chkExitF);
gtk_table_attach (GTK_TABLE (table10), chkExitF, 0, 2, 3, 4, gtk_table_attach(GTK_TABLE(table10), chkExitF, 0, 2, 3, 4, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, chkExitF, "Enable this to stop all attacking processes once a valid login/password pair is found (global)", NULL);
(GtkAttachOptions) (GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkExitF, "Enable this to stop all attacking processes once a valid login/password pair is found (global)", NULL);
chkNoErr = gtk_check_button_new_with_mnemonic ("Do not print messages about connection errors"); chkNoErr = gtk_check_button_new_with_mnemonic("Do not print messages about connection errors");
gtk_widget_set_name (chkNoErr, "chkNoErr"); gtk_widget_set_name(chkNoErr, "chkNoErr");
gtk_widget_show (chkNoErr); gtk_widget_show(chkNoErr);
gtk_table_attach (GTK_TABLE (table10), chkNoErr, 0, 2, 4, 5, gtk_table_attach(GTK_TABLE(table10), chkNoErr, 0, 2, 4, 5, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND), 0, 0);
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), gtk_tooltips_set_tip(tooltips, chkNoErr, "Do not print messages about connection errors", NULL);
(GtkAttachOptions) (GTK_EXPAND), 0, 0);
gtk_tooltips_set_tip (tooltips, chkNoErr, "Do not print messages about connection errors", NULL);
label30 = gtk_label_new("Performance Options"); label30 = gtk_label_new("Performance Options");
gtk_widget_set_name(label30, "label30"); gtk_widget_set_name(label30, "label30");
@ -847,25 +835,42 @@ GtkWidget *create_wndMain(void) {
gtk_widget_set_name(chkLocal, "chkLocal"); gtk_widget_set_name(chkLocal, "chkLocal");
gtk_widget_show(chkLocal); gtk_widget_show(chkLocal);
gtk_box_pack_start(GTK_BOX(hbox2), chkLocal, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox2), chkLocal, TRUE, TRUE, 0);
gtk_tooltips_set_tip(tooltips, chkLocal, "Just attack local accounts", NULL); gtk_tooltips_set_tip(tooltips, chkLocal, "Just attack local accounts (only valid for smb module)", NULL);
chkDomain = gtk_check_button_new_with_mnemonic("domain accounts"); chkDomain = gtk_check_button_new_with_mnemonic("domain accounts");
gtk_widget_set_name(chkDomain, "chkDomain"); gtk_widget_set_name(chkDomain, "chkDomain");
gtk_widget_show(chkDomain); gtk_widget_show(chkDomain);
gtk_box_pack_start(GTK_BOX(hbox2), chkDomain, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox2), chkDomain, TRUE, TRUE, 0);
gtk_tooltips_set_tip(tooltips, chkDomain, "Attack domain and local accounts", NULL); gtk_tooltips_set_tip(tooltips, chkDomain, "Attack domain and local accounts (only valid for smb module)", NULL);
chkNTLM = gtk_check_button_new_with_mnemonic("Interpret passes as NTLM hashes"); chkNTLM = gtk_check_button_new_with_mnemonic("Interpret passes as NTLM hashes");
gtk_widget_set_name(chkNTLM, "chkNTLM"); gtk_widget_set_name(chkNTLM, "chkNTLM");
gtk_widget_show(chkNTLM); gtk_widget_show(chkNTLM);
gtk_box_pack_start(GTK_BOX(hbox2), chkNTLM, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox2), chkNTLM, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, chkNTLM, "Interpret passes as NTML hashes", NULL); gtk_tooltips_set_tip(tooltips, chkNTLM, "Interpret passes as NTML hashes (valid for both smb and smb2 modules)", NULL);
label18 = gtk_label_new("SMB"); label18 = gtk_label_new("SMB");
gtk_widget_set_name(label18, "label18"); gtk_widget_set_name(label18, "label18");
gtk_widget_show(label18); gtk_widget_show(label18);
gtk_frame_set_label_widget(GTK_FRAME(frame6), label18); gtk_frame_set_label_widget(GTK_FRAME(frame6), label18);
fraSMB2 = gtk_frame_new(NULL);
gtk_widget_set_name(fraSMB2, "fraSMB2");
gtk_widget_show(fraSMB2);
gtk_box_pack_start(GTK_BOX(vbox4), fraSMB2, TRUE, TRUE, 0);
entSMB2Workgroup = gtk_entry_new();
gtk_widget_set_name(entSMB2Workgroup, "entSMB2Workgroup");
gtk_widget_show(entSMB2Workgroup);
gtk_container_add(GTK_CONTAINER(fraSMB2), entSMB2Workgroup);
gtk_tooltips_set_tip(tooltips, entSMB2Workgroup, "Workgroup to use for SMB authentication (only valid for smb2 module)", NULL);
gtk_entry_set_text(GTK_ENTRY(entSMB2Workgroup), "WORKGROUP");
lblSMB2 = gtk_label_new("SMB2 Workgroup");
gtk_widget_set_name(lblSMB2, "lblSMB2");
gtk_widget_show(lblSMB2);
gtk_frame_set_label_widget(GTK_FRAME(fraSMB2), lblSMB2);
frame7 = gtk_frame_new(NULL); frame7 = gtk_frame_new(NULL);
gtk_widget_set_name(frame7, "frame7"); gtk_widget_set_name(frame7, "frame7");
gtk_widget_show(frame7); gtk_widget_show(frame7);
@ -1015,18 +1020,18 @@ GtkWidget *create_wndMain(void) {
gtk_widget_show(statusbar); gtk_widget_show(statusbar);
gtk_box_pack_start(GTK_BOX(vbox1), statusbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), statusbar, FALSE, FALSE, 0);
g_signal_connect((gpointer) wndMain, "destroy", G_CALLBACK(on_wndMain_destroy), NULL); g_signal_connect((gpointer)wndMain, "destroy", G_CALLBACK(on_wndMain_destroy), NULL);
g_signal_connect((gpointer) quit1, "button-press-event", G_CALLBACK(on_quit1_activate), NULL); g_signal_connect((gpointer)quit1, "button-press-event", G_CALLBACK(on_quit1_activate), NULL);
g_signal_connect((gpointer) entTargetFile, "button_press_event", G_CALLBACK(on_entTargetFile_button_press_event), NULL); g_signal_connect((gpointer)entTargetFile, "button_press_event", G_CALLBACK(on_entTargetFile_button_press_event), NULL);
g_signal_connect((gpointer) entUsernameFile, "button_press_event", G_CALLBACK(on_entUsernameFile_button_press_event), NULL); g_signal_connect((gpointer)entUsernameFile, "button_press_event", G_CALLBACK(on_entUsernameFile_button_press_event), NULL);
g_signal_connect((gpointer) chkDisUser, "toggled", G_CALLBACK (on_chkDisUser_toggled), NULL); g_signal_connect((gpointer)chkDisUser, "toggled", G_CALLBACK(on_chkDisUser_toggled), NULL);
g_signal_connect((gpointer) entPassFile, "button_press_event", G_CALLBACK(on_entPassFile_button_press_event), NULL); g_signal_connect((gpointer)entPassFile, "button_press_event", G_CALLBACK(on_entPassFile_button_press_event), NULL);
g_signal_connect((gpointer) chkColon, "toggled", G_CALLBACK(on_chkColon_toggled), NULL); g_signal_connect((gpointer)chkColon, "toggled", G_CALLBACK(on_chkColon_toggled), NULL);
g_signal_connect((gpointer) entColonFile, "button_press_event", G_CALLBACK(on_entColonFile_button_press_event), NULL); g_signal_connect((gpointer)entColonFile, "button_press_event", G_CALLBACK(on_entColonFile_button_press_event), NULL);
g_signal_connect((gpointer) btnStart, "clicked", G_CALLBACK(on_btnStart_clicked), NULL); g_signal_connect((gpointer)btnStart, "clicked", G_CALLBACK(on_btnStart_clicked), NULL);
g_signal_connect((gpointer) btnStop, "clicked", G_CALLBACK(on_btnStop_clicked), NULL); g_signal_connect((gpointer)btnStop, "clicked", G_CALLBACK(on_btnStop_clicked), NULL);
g_signal_connect((gpointer) btnSave, "clicked", G_CALLBACK(on_btnSave_clicked), NULL); g_signal_connect((gpointer)btnSave, "clicked", G_CALLBACK(on_btnSave_clicked), NULL);
g_signal_connect((gpointer) btnClear, "clicked", G_CALLBACK(on_btnClear_clicked), NULL); g_signal_connect((gpointer)btnClear, "clicked", G_CALLBACK(on_btnClear_clicked), NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */ /* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF(wndMain, wndMain, "wndMain"); GLADE_HOOKUP_OBJECT_NO_REF(wndMain, wndMain, "wndMain");
@ -1067,7 +1072,7 @@ GtkWidget *create_wndMain(void) {
GLADE_HOOKUP_OBJECT(wndMain, radioUsername1, "radioUsername1"); GLADE_HOOKUP_OBJECT(wndMain, radioUsername1, "radioUsername1");
GLADE_HOOKUP_OBJECT(wndMain, chkUsernameLoop, "chkUsernameLoop"); GLADE_HOOKUP_OBJECT(wndMain, chkUsernameLoop, "chkUsernameLoop");
GLADE_HOOKUP_OBJECT(wndMain, radioUsername2, "radioUsername2"); GLADE_HOOKUP_OBJECT(wndMain, radioUsername2, "radioUsername2");
GLADE_HOOKUP_OBJECT (wndMain, chkDisUser, "chkDisUser"); GLADE_HOOKUP_OBJECT(wndMain, chkDisUser, "chkDisUser");
GLADE_HOOKUP_OBJECT(wndMain, label8, "label8"); GLADE_HOOKUP_OBJECT(wndMain, label8, "label8");
GLADE_HOOKUP_OBJECT(wndMain, frmPass, "frmPass"); GLADE_HOOKUP_OBJECT(wndMain, frmPass, "frmPass");
GLADE_HOOKUP_OBJECT(wndMain, table3, "table3"); GLADE_HOOKUP_OBJECT(wndMain, table3, "table3");
@ -1162,6 +1167,7 @@ GtkWidget *create_wndMain(void) {
GLADE_HOOKUP_OBJECT(wndMain, label4, "label4"); GLADE_HOOKUP_OBJECT(wndMain, label4, "label4");
GLADE_HOOKUP_OBJECT(wndMain, statusbar, "statusbar"); GLADE_HOOKUP_OBJECT(wndMain, statusbar, "statusbar");
GLADE_HOOKUP_OBJECT_NO_REF(wndMain, tooltips, "tooltips"); GLADE_HOOKUP_OBJECT_NO_REF(wndMain, tooltips, "tooltips");
GLADE_HOOKUP_OBJECT(wndMain, entSMB2Workgroup, "entSMB2Workgroup");
gtk_window_add_accel_group(GTK_WINDOW(wndMain), accel_group); gtk_window_add_accel_group(GTK_WINDOW(wndMain), accel_group);

View file

@ -8,19 +8,23 @@
#include <config.h> #include <config.h>
#endif #endif
#include <gtk/gtk.h> #include "callbacks.h"
#include <string.h>
#include "interface.h" #include "interface.h"
#include "support.h" #include "support.h"
#include "callbacks.h" #include <gtk/gtk.h>
#include <string.h>
char *hydra_path1 = "./hydra"; char *hydra_path1 = "./hydra";
char *hydra_path2 = "/usr/local/bin/hydra"; char *hydra_path2 = "/usr/local/bin/hydra";
char *hydra_path3 = "/usr/bin/hydra"; char *hydra_path3 = "/usr/bin/hydra";
char *hydra_path4 = "/data/data/com.termux/files/usr/bin/hydra";
char *hydra_path5 = "/data/data/com.termux/files/usr/local/bin/hydra";
GtkWidget *wndMain;
char *HYDRA_BIN;
guint message_id;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
extern GtkWidget *wndMain;
int i; int i;
extern guint message_id; extern guint message_id;
GtkWidget *output; GtkWidget *output;
@ -51,6 +55,10 @@ int main(int argc, char *argv[]) {
HYDRA_BIN = hydra_path2; HYDRA_BIN = hydra_path2;
} else if (g_file_test(hydra_path3, G_FILE_TEST_IS_EXECUTABLE)) { } else if (g_file_test(hydra_path3, G_FILE_TEST_IS_EXECUTABLE)) {
HYDRA_BIN = hydra_path3; HYDRA_BIN = hydra_path3;
} else if (g_file_test(hydra_path4, G_FILE_TEST_IS_EXECUTABLE)) {
HYDRA_BIN = hydra_path4;
} else if (g_file_test(hydra_path5, G_FILE_TEST_IS_EXECUTABLE)) {
HYDRA_BIN = hydra_path5;
} else { } else {
g_error("Please tell me where hydra is, use --hydra-path\n"); g_error("Please tell me where hydra is, use --hydra-path\n");
return -1; return -1;
@ -60,7 +68,6 @@ int main(int argc, char *argv[]) {
wndMain = create_wndMain(); wndMain = create_wndMain();
gtk_widget_show(wndMain); gtk_widget_show(wndMain);
/* if we can't use the new cool file chooser, the save button gets disabled */ /* if we can't use the new cool file chooser, the save button gets disabled */
#ifndef GTK_TYPE_FILE_CHOOSER #ifndef GTK_TYPE_FILE_CHOOSER
GtkWidget *btnSave; GtkWidget *btnSave;
@ -69,13 +76,12 @@ int main(int argc, char *argv[]) {
gtk_widget_set_sensitive(btnSave, FALSE); gtk_widget_set_sensitive(btnSave, FALSE);
#endif #endif
/* update the statusbar every now and then */ /* update the statusbar every now and then */
g_timeout_add(600, update_statusbar, NULL); g_timeout_add(600, update_statusbar, NULL);
/* we want bold text in the output window */ /* we want bold text in the output window */
output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput"); output = lookup_widget(GTK_WIDGET(wndMain), "txtOutput");
outputbuf = gtk_text_view_get_buffer((GtkTextView *) output); outputbuf = gtk_text_view_get_buffer((GtkTextView *)output);
gtk_text_buffer_create_tag(outputbuf, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(outputbuf, "bold", "weight", PANGO_WEIGHT_BOLD, NULL);
/* he ho, lets go! */ /* he ho, lets go! */

View file

@ -7,17 +7,17 @@
#include <config.h> #include <config.h>
#endif #endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "support.h" #include "support.h"
GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name) { GtkWidget *lookup_widget(GtkWidget *widget, const gchar *widget_name) {
GtkWidget *parent, *found_widget; GtkWidget *parent, *found_widget;
for (;;) { for (;;) {
@ -26,13 +26,13 @@ GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name) {
else else
parent = widget->parent; parent = widget->parent;
if (!parent) if (!parent)
parent = (GtkWidget *) g_object_get_data(G_OBJECT(widget), "GladeParentKey"); parent = (GtkWidget *)g_object_get_data(G_OBJECT(widget), "GladeParentKey");
if (parent == NULL) if (parent == NULL)
break; break;
widget = parent; widget = parent;
} }
found_widget = (GtkWidget *) g_object_get_data(G_OBJECT(widget), widget_name); found_widget = (GtkWidget *)g_object_get_data(G_OBJECT(widget), widget_name);
if (!found_widget) if (!found_widget)
g_warning("Widget not found: %s", widget_name); g_warning("Widget not found: %s", widget_name);
return found_widget; return found_widget;
@ -41,19 +41,16 @@ GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name) {
static GList *pixmaps_directories = NULL; static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */ /* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory(const gchar * directory) { void add_pixmap_directory(const gchar *directory) { pixmaps_directories = g_list_prepend(pixmaps_directories, g_strdup(directory)); }
pixmaps_directories = g_list_prepend(pixmaps_directories, g_strdup(directory));
}
/* This is an internally used function to find pixmap files. */ /* This is an internally used function to find pixmap files. */
static gchar *find_pixmap_file(const gchar * filename) { static gchar *find_pixmap_file(const gchar *filename) {
GList *elem; GList *elem;
/* We step through each of the pixmaps directory to find it. */ /* We step through each of the pixmaps directory to find it. */
elem = pixmaps_directories; elem = pixmaps_directories;
while (elem) { while (elem) {
gchar *pathname = g_strdup_printf("%s%s%s", (gchar *) elem->data, gchar *pathname = g_strdup_printf("%s%s%s", (gchar *)elem->data, G_DIR_SEPARATOR_S, filename);
G_DIR_SEPARATOR_S, filename);
if (g_file_test(pathname, G_FILE_TEST_EXISTS)) if (g_file_test(pathname, G_FILE_TEST_EXISTS))
return pathname; return pathname;
@ -64,7 +61,7 @@ static gchar *find_pixmap_file(const gchar * filename) {
} }
/* This is an internally used function to create pixmaps. */ /* This is an internally used function to create pixmaps. */
GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename) { GtkWidget *create_pixmap(GtkWidget *widget, const gchar *filename) {
gchar *pathname = NULL; gchar *pathname = NULL;
GtkWidget *pixmap; GtkWidget *pixmap;
@ -84,7 +81,7 @@ GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename) {
} }
/* This is an internally used function to create pixmaps. */ /* This is an internally used function to create pixmaps. */
GdkPixbuf *create_pixbuf(const gchar * filename) { GdkPixbuf *create_pixbuf(const gchar *filename) {
gchar *pathname = NULL; gchar *pathname = NULL;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GError *error = NULL; GError *error = NULL;
@ -109,7 +106,7 @@ GdkPixbuf *create_pixbuf(const gchar * filename) {
} }
/* This is used to set ATK action descriptions. */ /* This is used to set ATK action descriptions. */
void glade_set_atk_action_description(AtkAction * action, const gchar * action_name, const gchar * description) { void glade_set_atk_action_description(AtkAction *action, const gchar *action_name, const gchar *description) {
gint n_actions, i; gint n_actions, i;
n_actions = atk_action_get_n_actions(action); n_actions = atk_action_get_n_actions(action);

View file

@ -19,27 +19,24 @@
* or alternatively any widget in the component, and the name of the widget * or alternatively any widget in the component, and the name of the widget
* you want returned. * you want returned.
*/ */
GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name); GtkWidget *lookup_widget(GtkWidget *widget, const gchar *widget_name);
/* Use this function to set the directory containing installed pixmaps. */ /* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory(const gchar * directory); void add_pixmap_directory(const gchar *directory);
/* /*
* Private Functions. * Private Functions.
*/ */
/* This is used to create the pixmaps used in the interface. */ /* This is used to create the pixmaps used in the interface. */
GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename); GtkWidget *create_pixmap(GtkWidget *widget, const gchar *filename);
/* This is used to create the pixbufs used in the interface. */ /* This is used to create the pixbufs used in the interface. */
GdkPixbuf *create_pixbuf(const gchar * filename); GdkPixbuf *create_pixbuf(const gchar *filename);
/* This is used to set ATK action descriptions. */ /* This is used to set ATK action descriptions. */
void glade_set_atk_action_description(AtkAction * action, const gchar * action_name, const gchar * description); void glade_set_atk_action_description(AtkAction *action, const gchar *action_name, const gchar *description);
extern GtkWidget *wndMain;
GtkWidget *wndMain; extern char *HYDRA_BIN;
char *HYDRA_BIN; extern guint message_id;
guint message_id;

792
hydra-http-form.c Normal file → Executable file

File diff suppressed because it is too large Load diff

View file

@ -5,11 +5,11 @@ extern char *HYDRA_EXIT;
char *buf; char *buf;
static int32_t http_proxy_auth_mechanism = AUTH_ERROR; static int32_t http_proxy_auth_mechanism = AUTH_ERROR;
int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *hostname) { int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp, char *hostname) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[500], buffer2[500], mlogin[260], mpass[260], mhost[260]; char *login, *pass, buffer[500], buffer2[500], mlogin[260], mpass[260], mhost[260];
char url[260], host[30]; char url[260], host[30];
char *header = ""; /* XXX TODO */ char *header = ""; /* XXX TODO */
char *ptr; char *ptr;
int32_t auth = 0; int32_t auth = 0;
@ -19,7 +19,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
return 1; return 1;
} }
pass = hydra_get_next_password(); pass = hydra_get_next_password();
pass = empty; // ignored pass = empty; // ignored
strncpy(url, login, sizeof(url) - 1); strncpy(url, login, sizeof(url) - 1);
url[sizeof(url) - 1] = 0; url[sizeof(url) - 1] = 0;
@ -28,17 +28,17 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
ptr++; ptr++;
strncpy(mhost, ptr, sizeof(mhost) - 1); strncpy(mhost, ptr, sizeof(mhost) - 1);
mhost[sizeof(mhost) - 1] = 0; mhost[sizeof(mhost) - 1] = 0;
if ((ptr = index(mhost, '/')) != NULL) if ((ptr = strchr(mhost, '/')) != NULL)
*ptr = 0; *ptr = 0;
if ((ptr = index(mhost, ']')) != NULL) if ((ptr = strchr(mhost, ']')) != NULL)
*ptr = 0; *ptr = 0;
else if ((ptr = index(mhost, ':')) != NULL) else if ((ptr = strchr(mhost, ':')) != NULL)
*ptr = 0; *ptr = 0;
if (miscptr != NULL && index(miscptr, ':') != NULL) { if (miscptr != NULL && strchr(miscptr, ':') != NULL) {
strncpy(mlogin, miscptr, sizeof(mlogin) - 1); strncpy(mlogin, miscptr, sizeof(mlogin) - 1);
mlogin[sizeof(mlogin) - 1] = 0; mlogin[sizeof(mlogin) - 1] = 0;
ptr = index(mlogin, ':'); ptr = strchr(mlogin, ':');
*ptr++ = 0; *ptr++ = 0;
strncpy(mpass, ptr, sizeof(mpass) - 1); strncpy(mpass, ptr, sizeof(mpass) - 1);
mpass[sizeof(mpass) - 1] = 0; mpass[sizeof(mpass) - 1] = 0;
@ -46,12 +46,12 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
} }
if (http_proxy_auth_mechanism == AUTH_ERROR) { if (http_proxy_auth_mechanism == AUTH_ERROR) {
//send dummy request // send dummy request
sprintf(buffer, "GET %s HTTP/1.0\r\n%sUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, mhost, header); sprintf(buffer, "GET %s HTTP/1.0\r\n%sUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, mhost, header);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1; return 1;
//receive first 40x // receive first 40x
buf = hydra_receive_line(s); buf = hydra_receive_line(s);
while (buf != NULL && strstr(buf, "HTTP/") == NULL) { while (buf != NULL && strstr(buf, "HTTP/") == NULL) {
free(buf); free(buf);
@ -61,7 +61,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
if (debug) if (debug)
hydra_report(stderr, "S:%s\n", buf); hydra_report(stderr, "S:%s\n", buf);
//after the first query we should have been disconnected from web server // after the first query we should have been disconnected from web server
s = hydra_disconnect(s); s = hydra_disconnect(s);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
s = hydra_connect_tcp(ip, port); s = hydra_connect_tcp(ip, port);
@ -74,8 +74,11 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
if (hydra_strcasestr(buf, "Proxy-Authenticate: Basic") != NULL) { if (hydra_strcasestr(buf, "Proxy-Authenticate: Basic") != NULL) {
http_proxy_auth_mechanism = AUTH_BASIC; http_proxy_auth_mechanism = AUTH_BASIC;
sprintf(buffer2, "%.50s:%.50s", login, pass); sprintf(buffer2, "%.50s:%.50s", login, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, host, buffer2, header); sprintf(buffer,
"GET %s HTTP/1.0\r\n%sProxy-Authorization: Basic "
"%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
url, host, buffer2, header);
if (debug) if (debug)
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
@ -87,8 +90,8 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
buf = hydra_receive_line(s); buf = hydra_receive_line(s);
} }
//if server cut the connection, just exit cleanly or // if server cut the connection, just exit cleanly or
//this will be an infinite loop // this will be an infinite loop
if (buf == NULL) { if (buf == NULL) {
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] Server did not answer\n"); hydra_report(stderr, "[ERROR] Server did not answer\n");
@ -104,19 +107,23 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
char *pos = NULL; char *pos = NULL;
http_proxy_auth_mechanism = AUTH_NTLM; http_proxy_auth_mechanism = AUTH_NTLM;
//send auth and receive challenge // send auth and receive challenge
//send auth request: let the server send it's own hostname and domainname // send auth request: let the server send it's own hostname and
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL); // domainname
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2)); buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
/* to be portable, no snprintf, buffer is big enough so it can't overflow */ /* to be portable, no snprintf, buffer is big enough so it can't
//send the first.. * overflow */
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n", url, host, buf1, // send the first..
header); sprintf(buffer,
"GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: "
"Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n",
url, host, buf1, header);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1; return 1;
//receive challenge // receive challenge
free(buf); free(buf);
buf = hydra_receive_line(s); buf = hydra_receive_line(s);
while (buf != NULL && (pos = hydra_strcasestr(buf, "Proxy-Authenticate: NTLM ")) == NULL) { while (buf != NULL && (pos = hydra_strcasestr(buf, "Proxy-Authenticate: NTLM ")) == NULL) {
@ -134,17 +141,19 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
pos[str - pos] = 0; pos[str - pos] = 0;
} }
} }
//recover challenge // recover challenge
if (buf != NULL) { if (buf != NULL) {
if (strlen(buf) >= 4) if (strlen(buf) >= 4)
from64tobits((char *) buf1, pos); from64tobits((char *)buf1, pos);
free(buf); free(buf);
} }
//Send response // Send response
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL); buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2)); to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n", url, host, buf1, sprintf(buffer,
header); "GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: "
"Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n",
url, host, buf1, header);
if (debug) if (debug)
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
@ -161,7 +170,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
} else { } else {
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (hydra_strcasestr(buf, "Proxy-Authenticate: Digest") != NULL) { if (hydra_strcasestr(buf, "Proxy-Authenticate: Digest") != NULL) {
char *pbuffer; char *pbuffer, *result;
http_proxy_auth_mechanism = AUTH_DIGESTMD5; http_proxy_auth_mechanism = AUTH_DIGESTMD5;
pbuffer = hydra_strcasestr(buf, "Proxy-Authenticate: Digest "); pbuffer = hydra_strcasestr(buf, "Proxy-Authenticate: Digest ");
@ -169,8 +178,8 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0';
pbuffer = buffer2; pbuffer = buffer2;
sasl_digest_md5(pbuffer, login, pass, buffer, miscptr, "proxy", host, 0, header); result = sasl_digest_md5(pbuffer, login, pass, buffer, miscptr, "proxy", host, 0, header);
if (pbuffer == NULL) if (result == NULL)
return 3; return 3;
if (debug) if (debug)
@ -206,7 +215,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
} }
} }
// result analysis // result analysis
ptr = ((char *) index(buf, ' ')) + 1; ptr = ((char *)strchr(buf, ' ')) + 1;
if (*ptr == '2' || (*ptr == '3' && (*(ptr + 2) == '1' || *(ptr + 2) == '2')) || strncmp(ptr, "404", 4) == 0 || strncmp(ptr, "403", 4) == 0) { if (*ptr == '2' || (*ptr == '3' && (*(ptr + 2) == '1' || *(ptr + 2) == '2')) || strncmp(ptr, "404", 4) == 0 || strncmp(ptr, "403", 4) == 0) {
hydra_report_found_host(port, ip, "http-proxy", fp); hydra_report_found_host(port, ip, "http-proxy", fp);
if (fp != stdout) if (fp != stdout)
@ -214,7 +223,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
printf("[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string_beautiful(ip), url); printf("[%d][http-proxy-urlenum] host: %s url: %s\n", port, hydra_address2string_beautiful(ip), url);
hydra_completed_pair_found(); hydra_completed_pair_found();
} else { } else {
if (strncmp(ptr, "407", 3) == 0 /*|| strncmp(ptr, "401", 3) == 0 */ ) { if (strncmp(ptr, "407", 3) == 0 /*|| strncmp(ptr, "401", 3) == 0 */) {
hydra_report(stderr, "[ERROR] Proxy reports bad credentials!\n"); hydra_report(stderr, "[ERROR] Proxy reports bad credentials!\n");
return 3; return 3;
} }
@ -228,7 +237,7 @@ int32_t start_http_proxy_urlenum(int32_t s, char *ip, int32_t port, unsigned cha
return 1; return 1;
} }
void service_http_proxy_urlenum(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_http_proxy_urlenum(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_HTTP_PROXY, mysslport = PORT_HTTP_PROXY_SSL; int32_t myport = PORT_HTTP_PROXY, mysslport = PORT_HTTP_PROXY_SSL;
@ -239,33 +248,34 @@ void service_http_proxy_urlenum(char *ip, int32_t sp, unsigned char options, cha
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_http_proxy_urlenum(sock, ip, port, options, miscptr, fp, hostname); next_run = start_http_proxy_urlenum(sock, ip, port, options, miscptr, fp, hostname);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -278,13 +288,13 @@ void service_http_proxy_urlenum(char *ip, int32_t sp, unsigned char options, cha
} }
} }
int32_t service_http_proxy_urlenum_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_http_proxy_urlenum_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -292,9 +302,13 @@ int32_t service_http_proxy_urlenum_init(char *ip, int32_t sp, unsigned char opti
return 0; return 0;
} }
void usage_http_proxy_urlenum(const char* service) { void usage_http_proxy_urlenum(const char *service) {
printf("Module http-proxy-urlenum only uses the -L option, not -x or -p/-P option.\n" printf("Module http-proxy-urlenum only uses the -L option, not -x or -p/-P "
"option.\n"
"The -L loginfile must contain the URL list to try through the proxy.\n" "The -L loginfile must contain the URL list to try through the proxy.\n"
"The proxy credentials cann be put as the optional parameter, e.g.\n" "The proxy credentials cann be put as the optional parameter, e.g.\n"
" hydra -L urllist.txt -s 3128 target.com http-proxy-urlenum user:pass\n" " hydra -L urllist.txt http-proxy-urlenum://target.com:3128/user:pass\n\n"); " hydra -L urllist.txt -s 3128 target.com http-proxy-urlenum "
"user:pass\n"
" hydra -L urllist.txt "
"http-proxy-urlenum://target.com:3128/user:pass\n\n");
} }

View file

@ -5,12 +5,12 @@ extern char *HYDRA_EXIT;
static int32_t http_proxy_auth_mechanism = AUTH_ERROR; static int32_t http_proxy_auth_mechanism = AUTH_ERROR;
char *http_proxy_buf = NULL; char *http_proxy_buf = NULL;
int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *hostname) { int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp, char *hostname) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[500], buffer2[500]; char *login, *pass, buffer[5000], buffer2[4500];
char url[210], host[30]; char url[510], host[60];
char *header = ""; /* XXX TODO */ char *header = ""; /* XXX TODO */
char *ptr, *fooptr; char *ptr, *fooptr, *auth_hdr;
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
@ -21,23 +21,23 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
strcpy(url, "http://www.microsoft.com/"); strcpy(url, "http://www.microsoft.com/");
strcpy(host, "Host: www.microsoft.com\r\n"); strcpy(host, "Host: www.microsoft.com\r\n");
} else { } else {
sprintf(url, "%.200s", miscptr); sprintf(url, "%.500s", miscptr);
ptr = strstr(miscptr, "://"); // :// check is in hydra.c ptr = strstr(miscptr, "://"); // :// check is in hydra.c
sprintf(host, "Host: %.200s", ptr + 3); sprintf(host, "Host: %.50s", ptr + 3);
if ((ptr = index(host, '/')) != NULL) if ((ptr = strchr(host, '/')) != NULL)
*ptr = 0; *ptr = 0;
if ((ptr = index(host + 6, ':')) != NULL && host[0] != '[') if ((ptr = strchr(host + 6, ':')) != NULL && host[0] != '[')
*ptr = 0; *ptr = 0;
strcat(host, "\r\n"); strcat(host, "\r\n");
} }
if (http_proxy_auth_mechanism != AUTH_BASIC && (http_proxy_auth_mechanism == AUTH_ERROR || http_proxy_buf == NULL)) { if (http_proxy_auth_mechanism != AUTH_BASIC && (http_proxy_auth_mechanism == AUTH_ERROR || http_proxy_buf == NULL)) {
//send dummy request // send dummy request
sprintf(buffer, "GET %s HTTP/1.0\r\n%sUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, host, header); sprintf(buffer, "GET %s HTTP/1.0\r\n%sUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, host, header);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 3; return 3;
//receive first 40x // receive first 40x
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
while (http_proxy_buf != NULL && strstr(http_proxy_buf, "HTTP/") == NULL) { while (http_proxy_buf != NULL && strstr(http_proxy_buf, "HTTP/") == NULL) {
free(http_proxy_buf); free(http_proxy_buf);
@ -50,26 +50,26 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
return 3; return 3;
} }
if (debug) if (debug) {
hydra_report(stderr, "S:%s\n", http_proxy_buf); hydra_report(stderr, "S:%-.*s\n", (int)(strchr(http_proxy_buf, '\r') - http_proxy_buf), http_proxy_buf);
}
free(http_proxy_buf); while (http_proxy_buf != NULL && (auth_hdr = hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate:")) == NULL) {
http_proxy_buf = hydra_receive_line(s);
while (http_proxy_buf != NULL && hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate:") == NULL) {
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
} }
if (http_proxy_buf == NULL) { if (auth_hdr == NULL) {
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] Proxy seems not to require authentication\n"); hydra_report(stderr, "[ERROR] Proxy seems not to require authentication\n");
return 3; return 3;
} }
if (debug) if (debug) {
hydra_report(stderr, "S:%s\n", http_proxy_buf); hydra_report(stderr, "S:%-.*s\n", (int)(strchr(auth_hdr, '\r') - auth_hdr), auth_hdr);
}
//after the first query we should have been disconnected from web server // after the first query we should have been disconnected from web server
s = hydra_disconnect(s); s = hydra_disconnect(s);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
s = hydra_connect_tcp(ip, port); s = hydra_connect_tcp(ip, port);
@ -78,11 +78,15 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
} }
} }
if (http_proxy_auth_mechanism == AUTH_BASIC || hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: Basic") != NULL) { if (http_proxy_auth_mechanism == AUTH_BASIC || hydra_strcasestr(auth_hdr, "Proxy-Authenticate: Basic") != NULL) {
http_proxy_auth_mechanism = AUTH_BASIC; http_proxy_auth_mechanism = AUTH_BASIC;
auth_hdr = NULL;
sprintf(buffer2, "%.50s:%.50s", login, pass); sprintf(buffer2, "%.50s:%.50s", login, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", url, host, buffer2, header); sprintf(buffer,
"GET %s HTTP/1.0\r\n%sProxy-Authorization: Basic %s\r\nUser-Agent: "
"Mozilla/4.0 (Hydra)\r\n%s\r\n",
url, host, buffer2, header);
if (debug) if (debug)
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
@ -94,36 +98,41 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
} }
//if server cut the connection, just exit cleanly or // if server cut the connection, just exit cleanly or
//this will be an infinite loop // this will be an infinite loop
if (http_proxy_buf == NULL) { if (http_proxy_buf == NULL) {
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] Server did not answer\n"); hydra_report(stderr, "[ERROR] Server did not answer\n");
return 3; return 3;
} }
if (debug) if (debug) {
hydra_report(stderr, "S:%s\n", http_proxy_buf); hydra_report(stderr, "S:%-.*s\n", (int)(strchr(http_proxy_buf, '\r') - http_proxy_buf), http_proxy_buf);
}
} else { } else {
if (http_proxy_auth_mechanism == AUTH_NTLM || hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: NTLM") != NULL) { if (http_proxy_auth_mechanism == AUTH_NTLM || hydra_strcasestr(auth_hdr, "Proxy-Authenticate: NTLM") != NULL) {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
char *pos = NULL; char *pos = NULL;
http_proxy_auth_mechanism = AUTH_NTLM; http_proxy_auth_mechanism = AUTH_NTLM;
//send auth and receive challenge auth_hdr = NULL;
//send auth request: let the server send it's own hostname and domainname // send auth and receive challenge
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL); // send auth request: let the server send it's own hostname and domainname
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2)); buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
/* to be portable, no snprintf, buffer is big enough so it can't overflow */ /* to be portable, no snprintf, buffer is big enough so it can't overflow
//send the first.. */
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n", url, host, buf1, header); // send the first..
sprintf(buffer,
"GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: "
"Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n",
url, host, buf1, header);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 3; return 3;
//receive challenge // receive challenge
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
while (http_proxy_buf != NULL && (pos = hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: NTLM ")) == NULL) { while (http_proxy_buf != NULL && (pos = hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: NTLM ")) == NULL) {
@ -141,24 +150,27 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
pos[str - pos] = 0; pos[str - pos] = 0;
} }
} }
//recover challenge // recover challenge
if (http_proxy_buf != NULL && strlen(http_proxy_buf) >= 4) { if (http_proxy_buf != NULL && strlen(http_proxy_buf) >= 4) {
from64tobits((char *) buf1, pos); from64tobits((char *)buf1, pos);
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = NULL; http_proxy_buf = NULL;
return 3; return 3;
} }
//Send response // Send response
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL); buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2)); to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n", url, host, buf1, header); sprintf(buffer,
"GET %s HTTP/1.0\r\n%sProxy-Authorization: NTLM %s\r\nUser-Agent: "
"Mozilla/4.0 (Hydra)\r\nProxy-Connection: keep-alive\r\n%s\r\n",
url, host, buf1, header);
if (debug) if (debug)
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 3; return 3;
if (http_proxy_buf != NULL) if (http_proxy_buf != NULL)
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
while (http_proxy_buf != NULL && strstr(http_proxy_buf, "HTTP/1.") == NULL) { while (http_proxy_buf != NULL && strstr(http_proxy_buf, "HTTP/1.") == NULL) {
free(http_proxy_buf); free(http_proxy_buf);
@ -169,19 +181,19 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
return 3; return 3;
} else { } else {
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: Digest") != NULL) { if (hydra_strcasestr(auth_hdr, "Proxy-Authenticate: Digest") != NULL) {
char *pbuffer, *result;
char *pbuffer;
http_proxy_auth_mechanism = AUTH_DIGESTMD5; http_proxy_auth_mechanism = AUTH_DIGESTMD5;
auth_hdr = NULL;
pbuffer = hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: Digest "); pbuffer = hydra_strcasestr(http_proxy_buf, "Proxy-Authenticate: Digest ");
strncpy(buffer, pbuffer + strlen("Proxy-Authenticate: Digest "), sizeof(buffer)); strncpy(buffer, pbuffer + strlen("Proxy-Authenticate: Digest "), sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0';
pbuffer = NULL; pbuffer = NULL;
fooptr = buffer2; fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "proxy", host, 0, header); result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "proxy", host, 0, header);
if (fooptr == NULL) if (result == NULL)
return 3; return 3;
if (debug) if (debug)
@ -196,8 +208,9 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
http_proxy_buf = hydra_receive_line(s); http_proxy_buf = hydra_receive_line(s);
} }
if (debug && http_proxy_buf != NULL) if (debug && http_proxy_buf != NULL) {
hydra_report(stderr, "S:%s\n", http_proxy_buf); hydra_report(stderr, "S:%-.*s\n", (int)(strchr(http_proxy_buf, '\r') - http_proxy_buf), http_proxy_buf);
}
if (http_proxy_buf == NULL) if (http_proxy_buf == NULL)
return 3; return 3;
@ -205,9 +218,10 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
} else } else
#endif #endif
{ {
if (http_proxy_buf != NULL) { if (auth_hdr != NULL) {
// buf[strlen(http_proxy_buf) - 1] = '\0'; // buf[strlen(http_proxy_buf) - 1] = '\0';
hydra_report(stderr, "Unsupported Auth type:\n%s\n", http_proxy_buf); hydra_report(stderr, "Unsupported Auth type:\n%-.*s\n", (int)(strchr(http_proxy_buf, '\r') - auth_hdr), auth_hdr);
auth_hdr = NULL;
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = NULL; http_proxy_buf = NULL;
} else { } else {
@ -218,15 +232,15 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
} }
} }
ptr = ((char *) index(http_proxy_buf, ' ')) + 1; ptr = ((char *)strchr(http_proxy_buf, ' ')) + 1;
if (*ptr == '2' || (*ptr == '3' && *(ptr + 2) == '1') || (*ptr == '3' && *(ptr + 2) == '2')) { if (*ptr == '2' || (*ptr == '3' && *(ptr + 2) == '1') || (*ptr == '3' && *(ptr + 2) == '2') || (*ptr == '4' && *(ptr + 2) == '4')) {
hydra_report_found_host(port, ip, "http-proxy", fp); hydra_report_found_host(port, ip, "http-proxy", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
free(http_proxy_buf); free(http_proxy_buf);
http_proxy_buf = NULL; http_proxy_buf = NULL;
} else { } else {
if (*ptr != '4') if (*ptr != '4')
hydra_report(stderr, "[INFO] Unusual return code: %c for %s:%s\n", (char) *(index(http_proxy_buf, ' ') + 1), login, pass); hydra_report(stderr, "[INFO] Unusual return code: %c for %s:%s\n", (char)*(strchr(http_proxy_buf, ' ') + 1), login, pass);
else if (verbose && *(ptr + 2) == '3') else if (verbose && *(ptr + 2) == '3')
hydra_report(stderr, "[INFO] Potential success, could be false positive: %s:%s\n", login, pass); hydra_report(stderr, "[INFO] Potential success, could be false positive: %s:%s\n", login, pass);
hydra_completed_pair(); hydra_completed_pair();
@ -246,7 +260,7 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
return 1; return 1;
} }
void service_http_proxy(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_http_proxy(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_HTTP_PROXY, mysslport = PORT_HTTP_PROXY_SSL; int32_t myport = PORT_HTTP_PROXY, mysslport = PORT_HTTP_PROXY_SSL;
@ -257,36 +271,37 @@ void service_http_proxy(char *ip, int32_t sp, unsigned char options, char *miscp
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (http_proxy_buf != NULL) if (http_proxy_buf != NULL)
free(http_proxy_buf); free(http_proxy_buf);
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */
if (sock < 0) {
if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_http_proxy(sock, ip, port, options, miscptr, fp, hostname); next_run = start_http_proxy(sock, ip, port, options, miscptr, fp, hostname);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -299,13 +314,13 @@ void service_http_proxy(char *ip, int32_t sp, unsigned char options, char *miscp
} }
} }
int32_t service_http_proxy_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_http_proxy_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -313,7 +328,9 @@ int32_t service_http_proxy_init(char *ip, int32_t sp, unsigned char options, cha
return 0; return 0;
} }
void usage_http_proxy(const char* service) { void usage_http_proxy(const char *service) {
printf("Module http-proxy is optionally taking the page to authenticate at.\n" printf("Module http-proxy is optionally taking the page to authenticate at.\n"
"Default is http://www.microsoft.com/)\n" "Basic, DIGEST-MD5 and NTLM are supported and negotiated automatically.\n\n"); "Default is http://www.microsoft.com/)\n"
"Basic, DIGEST-MD5 and NTLM are supported and negotiated "
"automatically.\n\n");
} }

479
hydra-http.c Normal file → Executable file
View file

@ -5,15 +5,20 @@ extern char *HYDRA_EXIT;
char *webtarget = NULL; char *webtarget = NULL;
char *slash = "/"; char *slash = "/";
char *http_buf = NULL; char *http_buf = NULL;
int32_t webport, freemischttp = 0;
int32_t http_auth_mechanism = AUTH_BASIC;
int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *type, ptr_header_node ptr_head) { #define END_CONDITION_MAX_LEN 100
static char end_condition[END_CONDITION_MAX_LEN];
int end_condition_type = -1;
int32_t webport;
int32_t http_auth_mechanism = AUTH_UNASSIGNED;
int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp, char *type, ptr_header_node ptr_head) {
char *empty = ""; char *empty = "";
char *login, *pass, *buffer, buffer2[500]; char *login, *pass, *buffer, buffer2[500];
char *header; char *header;
char *ptr, *fooptr; char *ptr, *fooptr;
int32_t complete_line = 0; int32_t complete_line = 0, buffer_size;
char tmpreplybuf[1024] = "", *tmpreplybufptr; char tmpreplybuf[1024] = "", *tmpreplybufptr;
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
@ -26,7 +31,8 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
header = stringify_headers(&ptr_head); header = stringify_headers(&ptr_head);
if(!(buffer = malloc(strlen(header) + 500))) { buffer_size = strlen(header) + 500;
if (!(buffer = malloc(buffer_size))) {
free(header); free(header);
return 3; return 3;
} }
@ -41,130 +47,153 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
switch (http_auth_mechanism) { switch (http_auth_mechanism) {
case AUTH_BASIC: case AUTH_BASIC:
sprintf(buffer2, "%.50s:%.50s", login, pass); sprintf(buffer2, "%.50s:%.50s", login, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
/* again: no snprintf to be portable. don't worry, buffer can't overflow */ /* again: no snprintf to be portable. don't worry, buffer can't overflow */
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL) if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL)
sprintf(buffer, "%s http://%s:%d%.250s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: Basic %s\r\nProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", sprintf(buffer,
type, webtarget, webport, miscptr, webtarget, buffer2, proxy_authentication[selected_proxy], header); "%s http://%s%.250s HTTP/1.1\r\nHost: %s\r\nConnection: "
"close\r\nAuthorization: Basic %s\r\nProxy-Authorization: Basic "
"%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
type, webtarget, miscptr, webtarget, buffer2, proxy_authentication[selected_proxy], header);
else { else {
if (use_proxy == 1) if (use_proxy == 1)
sprintf(buffer, "%s http://%s:%d%.250s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", sprintf(buffer,
type, webtarget, webport, miscptr, webtarget, buffer2, header); "%s http://%s%.250s HTTP/1.1\r\nHost: %s\r\nConnection: "
"close\r\nAuthorization: Basic %s\r\nUser-Agent: Mozilla/4.0 "
"(Hydra)\r\n%s\r\n",
type, webtarget, miscptr, webtarget, buffer2, header);
else else
sprintf(buffer, "%s %.250s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n", type, miscptr, webtarget, buffer2, header); sprintf(buffer,
"%s %.250s HTTP/1.1\r\nHost: %s\r\nConnection: "
"close\r\nAuthorization: Basic %s\r\nUser-Agent: Mozilla/4.0 "
"(Hydra)\r\n%s\r\n",
type, miscptr, webtarget, buffer2, header);
} }
if (debug) if (debug)
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
break; break;
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_DIGESTMD5:{ case AUTH_DIGESTMD5: {
char *pbuffer; char *pbuffer, *result;
pbuffer = hydra_strcasestr(http_buf, "WWW-Authenticate: Digest "); pbuffer = hydra_strcasestr(http_buf, "WWW-Authenticate: Digest ");
strncpy(buffer, pbuffer + strlen("WWW-Authenticate: Digest "), sizeof(buffer)); strncpy(buffer, pbuffer + strlen("WWW-Authenticate: Digest "), buffer_size - 1);
buffer[sizeof(buffer) - 1] = '\0'; buffer[buffer_size - 1] = '\0';
fooptr = buffer2; fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, type, webtarget, webport, header); result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, type, webtarget, webport, header);
if (fooptr == NULL) { if (result == NULL) {
free(buffer); free(buffer);
free(header); free(header);
return 3; return 3;
}
if (debug)
hydra_report(stderr, "C:%s\n", buffer2);
strcpy(buffer, buffer2);
} }
break;
if (debug)
hydra_report(stderr, "C:%s\n", buffer2);
strcpy(buffer, buffer2);
} break;
#endif #endif
case AUTH_NTLM:{ case AUTH_NTLM: {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
char *pos = NULL; char *pos = NULL;
//send auth and receive challenge // send auth and receive challenge
//send auth request: let the server send it's own hostname and domainname // send auth request: let the server send it's own hostname and domainname
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL); buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2)); to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
/* to be portable, no snprintf, buffer is big enough so it can't overflow */ /* to be portable, no snprintf, buffer is big enough so it can't overflow */
//send the first.. // send the first..
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL) if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL)
sprintf(buffer,
"%s http://%s%s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
"%s\r\nProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 "
"(Hydra)\r\n%s\r\n",
type, webtarget, miscptr, webtarget, buf1, proxy_authentication[selected_proxy], header);
else {
if (use_proxy == 1)
sprintf(buffer, sprintf(buffer,
"%s http://%s:%d%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n", "%s http://%s%s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
type, webtarget, webport, miscptr, webtarget, buf1, proxy_authentication[selected_proxy], header); "%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
else { type, webtarget, miscptr, webtarget, buf1, header);
if (use_proxy == 1) else
sprintf(buffer, "%s http://%s:%d%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n",
type, webtarget, webport, miscptr, webtarget, buf1, header);
else
sprintf(buffer, "%s %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n", type, miscptr, webtarget,
buf1, header);
}
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
free(buffer);
free(header);
return 1;
}
//receive challenge
if (http_buf != NULL)
free(http_buf);
http_buf = hydra_receive_line(s);
while (http_buf != NULL && (pos = hydra_strcasestr(http_buf, "WWW-Authenticate: NTLM ")) == NULL) {
free(http_buf);
http_buf = hydra_receive_line(s);
}
if (http_buf == NULL) {
free(buffer);
free(header);
return 1;
}
if (pos != NULL) {
char *str;
pos += 23;
if ((str = strchr(pos, '\r')) != NULL) {
pos[str - pos] = 0;
}
if ((str = strchr(pos, '\n')) != NULL) {
pos[str - pos] = 0;
}
}
//recover challenge
from64tobits((char *) buf1, pos);
free(http_buf);
http_buf = NULL;
//Send response
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2));
//create the auth response
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL)
sprintf(buffer, sprintf(buffer,
"%s http://%s:%d%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n", "%s %s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
type, webtarget, webport, miscptr, webtarget, buf1, proxy_authentication[selected_proxy], header); "%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
else { type, miscptr, webtarget, buf1, header);
if (use_proxy == 1)
sprintf(buffer, "%s http://%s:%d%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n",
type, webtarget, webport, miscptr, webtarget, buf1, header);
else
sprintf(buffer, "%s %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nAuthorization: NTLM %s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\nConnection: keep-alive\r\n%s\r\n", type, miscptr, webtarget,
buf1, header);
}
if (debug)
hydra_report(stderr, "C:%s\n", buffer);
} }
break;
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
free(buffer);
free(header);
return 1;
}
// receive challenge
if (http_buf != NULL)
free(http_buf);
http_buf = hydra_receive_line(s);
if (http_buf == NULL) {
if (verbose)
hydra_report(stderr, "[ERROR] Server did not answer\n");
free(buffer);
free(header);
return 3;
}
pos = hydra_strcasestr(http_buf, "WWW-Authenticate: NTLM ");
if (pos != NULL) {
char *str;
pos += 23;
if ((str = strchr(pos, '\r')) != NULL) {
pos[str - pos] = 0;
}
if ((str = strchr(pos, '\n')) != NULL) {
pos[str - pos] = 0;
}
} else {
hydra_report(stderr, "[ERROR] It is not NTLM authentication type\n");
return 3;
}
// recover challenge
from64tobits((char *)buf1, pos);
free(http_buf);
http_buf = NULL;
// Send response
buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
// create the auth response
if (use_proxy == 1 && proxy_authentication[selected_proxy] != NULL)
sprintf(buffer,
"%s http://%s%s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
"%s\r\nProxy-Authorization: Basic %s\r\nUser-Agent: Mozilla/4.0 "
"(Hydra)\r\n%s\r\n",
type, webtarget, miscptr, webtarget, buf1, proxy_authentication[selected_proxy], header);
else {
if (use_proxy == 1)
sprintf(buffer,
"%s http://%s%s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
"%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
type, webtarget, miscptr, webtarget, buf1, header);
else
sprintf(buffer,
"%s %s HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM "
"%s\r\nUser-Agent: Mozilla/4.0 (Hydra)\r\n%s\r\n",
type, miscptr, webtarget, buf1, header);
}
if (debug)
hydra_report(stderr, "C:%s\n", buffer);
} break;
} }
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -179,8 +208,9 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
complete_line = 0; complete_line = 0;
tmpreplybuf[0] = 0; tmpreplybuf[0] = 0;
while (http_buf != NULL && (strstr(http_buf, "HTTP/1.") == NULL || (index(http_buf, '\n') == NULL && complete_line == 0))) { while (http_buf != NULL && (strstr(http_buf, "HTTP/1.") == NULL || (strchr(http_buf, '\n') == NULL && complete_line == 0))) {
if (debug) printf("il: %d, tmpreplybuf: %s, http_buf: %s\n", complete_line, tmpreplybuf, http_buf); if (debug)
printf("il: %d, tmpreplybuf: %s, http_buf: %s\n", complete_line, tmpreplybuf, http_buf);
if (tmpreplybuf[0] == 0 && strstr(http_buf, "HTTP/1.") != NULL) { if (tmpreplybuf[0] == 0 && strstr(http_buf, "HTTP/1.") != NULL) {
strncpy(tmpreplybuf, http_buf, sizeof(tmpreplybuf) - 1); strncpy(tmpreplybuf, http_buf, sizeof(tmpreplybuf) - 1);
tmpreplybuf[sizeof(tmpreplybuf) - 1] = 0; tmpreplybuf[sizeof(tmpreplybuf) - 1] = 0;
@ -193,7 +223,8 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
strcat(tmpreplybufptr, http_buf); strcat(tmpreplybufptr, http_buf);
free(http_buf); free(http_buf);
http_buf = tmpreplybufptr; http_buf = tmpreplybufptr;
if (debug) printf("http_buf now: %s\n", http_buf); if (debug)
printf("http_buf now: %s\n", http_buf);
} }
} else { } else {
free(http_buf); free(http_buf);
@ -201,8 +232,8 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
} }
//if server cut the connection, just exit cleanly or // if server cut the connection, just exit cleanly or
//this will be an infinite loop // this will be an infinite loop
if (http_buf == NULL) { if (http_buf == NULL) {
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] Server did not answer\n"); hydra_report(stderr, "[ERROR] Server did not answer\n");
@ -214,23 +245,35 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
if (debug) if (debug)
hydra_report(stderr, "S:%s\n", http_buf); hydra_report(stderr, "S:%s\n", http_buf);
ptr = ((char *) index(http_buf, ' ')); ptr = ((char *)strchr(http_buf, ' '));
if (ptr != NULL) if (ptr != NULL)
ptr++; ptr++;
if (ptr != NULL && (*ptr == '2' || *ptr == '3' || strncmp(ptr, "403", 3) == 0 || strncmp(ptr, "404", 3) == 0)) { if (ptr != NULL && (*ptr == '2' || *ptr == '3' || strncmp(ptr, "403", 3) == 0 || strncmp(ptr, "404", 3) == 0)) {
hydra_report_found_host(port, ip, "www", fp); #ifdef HAVE_PCRE
hydra_completed_pair_found(); if (end_condition_type >= 0 && hydra_string_match(http_buf, end_condition) != end_condition_type) {
#else
if (end_condition_type >= 0 && (strstr(http_buf, end_condition) == NULL ? 0 : 1) != end_condition_type) {
#endif
if (debug)
hydra_report(stderr, "End condition not match continue.\n");
hydra_completed_pair();
} else {
if (debug)
hydra_report(stderr, "END condition %s match.\n", end_condition);
hydra_report_found_host(port, ip, "www", fp);
hydra_completed_pair_found();
}
if (http_buf != NULL) { if (http_buf != NULL) {
free(http_buf); free(http_buf);
http_buf = NULL; http_buf = NULL;
} }
} else { } else {
if (ptr != NULL && *ptr != '4') if (ptr != NULL && *ptr != '4')
fprintf(stderr, "[WARNING] Unusual return code: %.3s for %s:%s\n", (char *) ptr, login, pass); fprintf(stderr, "[WARNING] Unusual return code: %.3s for %s:%s\n", (char *)ptr, login, pass);
//the first authentication type failed, check the type from server header // the first authentication type failed, check the type from server header
if ((hydra_strcasestr(http_buf, "WWW-Authenticate: Basic") == NULL) && (http_auth_mechanism == AUTH_BASIC)) { if ((hydra_strcasestr(http_buf, "WWW-Authenticate: Basic") == NULL) && (http_auth_mechanism == AUTH_BASIC)) {
//seems the auth supported is not Basic shceme so testing further // seems the auth supported is not Basic scheme so testing further
int32_t find_auth = 0; int32_t find_auth = 0;
if (hydra_strcasestr(http_buf, "WWW-Authenticate: NTLM") != NULL) { if (hydra_strcasestr(http_buf, "WWW-Authenticate: NTLM") != NULL) {
@ -245,56 +288,41 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
#endif #endif
if (find_auth) { if (find_auth) {
// free(http_buf); // free(http_buf);
// http_buf = NULL; // http_buf = NULL;
free(buffer); free(buffer);
free(header); free(header);
return 1; return 1;
} }
} }
hydra_completed_pair(); hydra_completed_pair();
} }
// free(http_buf); // free(http_buf);
// http_buf = NULL; // http_buf = NULL;
free(buffer); free(buffer);
free(header); free(header);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
return 1; return 1;
} }
void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname, char *type) { void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname, char *type) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_HTTP, mysslport = PORT_HTTP_SSL; int32_t myport = PORT_HTTP, mysslport = PORT_HTTP_SSL;
char *ptr, *ptr2; char *ptr, *ptr2;
ptr_header_node ptr_head = NULL; ptr_header_node ptr_head = NULL;
#ifdef AF_INET6
unsigned char addr6[sizeof(struct in6_addr)];
#endif
hydra_register_socket(sp); hydra_register_socket(sp);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return; return;
if ((webtarget = strstr(miscptr, "://")) != NULL) { if (strlen(miscptr) == 0)
webtarget += strlen("://"); miscptr = strdup("/");
if ((ptr2 = index(webtarget, ':')) != NULL) { /* step over port if present */
*ptr2 = 0;
ptr2++;
ptr = ptr2;
if (*ptr == '/' || (ptr = index(ptr2, '/')) != NULL)
miscptr = ptr;
else
miscptr = slash; /* to make things easier to user */
} else if ((ptr2 = index(webtarget, '/')) != NULL) {
miscptr = malloc(strlen(ptr2) + 1);
freemischttp = 1;
strcpy(miscptr, ptr2);
*ptr2 = 0;
} else
webtarget = hostname;
} else
if (strlen(miscptr) == 0)
miscptr = strdup("/");
if (webtarget == NULL)
webtarget = hostname;
if (port != 0) if (port != 0)
webport = port; webport = port;
else if ((options & OPTION_SSL) == 0) else if ((options & OPTION_SSL) == 0)
@ -302,6 +330,27 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
else else
webport = mysslport; webport = mysslport;
/* normalise the webtarget for ipv6/port number */
webtarget = malloc(strlen(hostname) + 1 /* null */ + 6 /* :65535 */
#ifdef AF_INET6
+ 2 /* [] */
#endif
);
#ifdef AF_INET6
/* let libc decide if target is an ipv6 address */
if (inet_pton(AF_INET6, hostname, addr6)) {
ptr = webtarget + sprintf(webtarget, "[%s]", hostname);
} else {
#endif
ptr = webtarget + sprintf(webtarget, "%s", hostname);
#ifdef AF_INET6
}
#endif
if (options & OPTION_SSL && webport != PORT_HTTP_SSL || !(options & OPTION_SSL) && webport != PORT_HTTP) {
sprintf(ptr, ":%d", webport);
}
ptr = NULL;
/* Advance to options string */ /* Advance to options string */
ptr = miscptr; ptr = miscptr;
while (*ptr != 0 && (*ptr != ':' || *(ptr - 1) == '\\')) while (*ptr != 0 && (*ptr != ':' || *(ptr - 1) == '\\'))
@ -310,49 +359,48 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
*ptr++ = 0; *ptr++ = 0;
optional1 = ptr; optional1 = ptr;
if (!parse_options(optional1, &ptr_head)) if (!parse_options(optional1,
&ptr_head)) // this function is in hydra-http-form.c !!
run = 4; run = 4;
if (http_auth_mechanism == AUTH_UNASSIGNED)
http_auth_mechanism = AUTH_BASIC;
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
if (freemischttp) if (quiet != 1)
free(miscptr); fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_child_exit(1);
hydra_child_exit(1); }
} next_run = 2;
next_run = 2; break;
break; }
} case 2: /* run the cracking function */
case 2: /* run the cracking function */ next_run = start_http(sock, ip, port, options, miscptr, fp, type, ptr_head);
next_run = start_http(sock, ip, port, options, miscptr, fp, type, ptr_head); break;
break; case 3: /* clean exit */
case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if (freemischttp)
free(miscptr);
hydra_child_exit(0); hydra_child_exit(0);
return; return;
default: default:
if (freemischttp)
free(miscptr);
fprintf(stderr, "[ERROR] Caught unknown return code, exiting!\n"); fprintf(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0); hydra_child_exit(0);
} }
@ -360,35 +408,78 @@ void service_http(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
void service_http_get(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_http_get(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_http(ip, sp, options, miscptr, fp, port, hostname, "GET"); }
service_http(ip, sp, options, miscptr, fp, port, hostname, "GET");
}
void service_http_post(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_http_post(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_http(ip, sp, options, miscptr, fp, port, hostname, "POST"); }
service_http(ip, sp, options, miscptr, fp, port, hostname, "POST");
}
void service_http_head(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_http_head(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_http(ip, sp, options, miscptr, fp, port, hostname, "HEAD"); }
service_http(ip, sp, options, miscptr, fp, port, hostname, "HEAD");
}
int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
/*POU CODE */
char *start = strstr(miscptr, "F=");
if (start == NULL)
start = strstr(miscptr, "S=");
if (start != NULL) {
if (start[0] == 'F')
end_condition_type = 0;
else
end_condition_type = 1;
int condition_len = strlen(start);
memset(end_condition, 0, END_CONDITION_MAX_LEN);
if (condition_len >= END_CONDITION_MAX_LEN) {
hydra_report(stderr, "Condition string cannot be bigger than %u.", END_CONDITION_MAX_LEN);
return -1;
}
// copy condition witout starting string (F= or S= 2char)
strncpy(end_condition, start + 2, condition_len - 2);
if (debug)
hydra_report(stderr, "End condition is %s, mod is %d\n", end_condition, end_condition_type);
if (*(start - 1) == ' ')
start--;
memset(start, '\0', condition_len);
if (debug)
hydra_report(stderr, "Modified options:%s\n", miscptr);
} else {
if (debug)
hydra_report(stderr, "Condition not found\n");
}
return 0; return 0;
} }
void usage_http(const char* service) { void usage_http(const char *service) {
printf("Module %s requires the page to authenticate.\n" printf("Module %s requires the page to authenticate.\n"
"The following parameters are optional:\n" "The following parameters are optional:\n"
" (h|H)=My-Hdr\\: foo to send a user defined HTTP header with each request\n" " (a|A)=auth-type specify authentication mechanism to use: BASIC, "
"For example: \"/secret\" or \"http://bla.com/foo/bar:H=Cookie\\: sessid=aaaa\" or \"https://test.com:8080/members\"\n\n", service); "NTLM or MD5\n"
" (h|H)=My-Hdr\\: foo to send a user defined HTTP header with each "
"request\n"
" (F|S)=check for text in the HTTP reply. S= means if this text is "
"found, a\n"
" valid account has been found, F= means if this string is "
"present the\n"
" combination is invalid. Note: this must be the last option "
"supplied.\n"
"For example: \"/secret\" or \"http://bla.com/foo/bar:H=Cookie\\: "
"sessid=aaaa\" or \"https://test.com:8080/members:A=NTLM\"\n"
"To attack multiple targets, you can use the -M option with a file "
"containing the targets and their parameters.\n"
"Example file content:\n"
" localhost:5000/protected:A=BASIC\n"
" localhost:5002/protected_path:A=NTLM\n"
" ...\n\n",
service);
} }

View file

@ -4,10 +4,10 @@
#include "hydra-mod.h" #include "hydra-mod.h"
/* HTTP Header Types */ /* HTTP Header Types */
#define HEADER_TYPE_USERHEADER 'h' #define HEADER_TYPE_USERHEADER 'h'
#define HEADER_TYPE_USERHEADER_REPL 'H' #define HEADER_TYPE_USERHEADER_REPL 'H'
#define HEADER_TYPE_DEFAULT 'D' #define HEADER_TYPE_DEFAULT 'D'
#define HEADER_TYPE_DEFAULT_REPL 'd' #define HEADER_TYPE_DEFAULT_REPL 'd'
typedef struct header_node t_header_node, *ptr_header_node; typedef struct header_node t_header_node, *ptr_header_node;
@ -15,7 +15,7 @@ extern char *webtarget;
extern char *slash; extern char *slash;
extern char *optional1; extern char *optional1;
extern int32_t parse_options(char *miscptr, ptr_header_node * ptr_head); extern int32_t parse_options(char *miscptr, ptr_header_node *ptr_head);
extern int32_t add_header(ptr_header_node * ptr_head, char *header, char *value, char type); extern int32_t add_header(ptr_header_node *ptr_head, char *header, char *value, char type);
extern char *stringify_headers(ptr_header_node *ptr_head); extern char *stringify_headers(ptr_header_node *ptr_head);
#endif #endif

View file

@ -4,32 +4,10 @@ extern char *HYDRA_EXIT;
extern int32_t child_head_no; extern int32_t child_head_no;
int32_t seq = 1; int32_t seq = 1;
const unsigned char icq5_table[] = { const unsigned char icq5_table[] = {0x59, 0x60, 0x37, 0x6B, 0x65, 0x62, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x60, 0x57, 0x5B, 0x3D, 0x5E, 0x34, 0x6D, 0x36, 0x50, 0x3F, 0x6F, 0x67, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x47, 0x63, 0x39, 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x31, 0x64, 0x35, 0x5A, 0x4A, 0x42, 0x56, 0x40, 0x67, 0x53, 0x41, 0x07, 0x6C, 0x49, 0x58, 0x3B, 0x4D, 0x46, 0x68, 0x43, 0x69, 0x48,
0x59, 0x60, 0x37, 0x6B, 0x65, 0x62, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x33, 0x31, 0x44, 0x65, 0x62, 0x46, 0x48, 0x53, 0x41, 0x07, 0x6C, 0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x4E, 0x6C, 0x49, 0x38, 0x4B, 0x55, 0x4A, 0x62, 0x46, 0x48, 0x33, 0x51, 0x34, 0x6D, 0x36, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x63, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64, 0x35, 0x5A, 0x6A, 0x52, 0x6E, 0x3C, 0x51, 0x34, 0x6D, 0x36, 0x50, 0x5F, 0x5F, 0x3F, 0x4F, 0x37, 0x4B, 0x35,
0x59, 0x60, 0x57, 0x5B, 0x3D, 0x5E, 0x34, 0x6D, 0x36, 0x50, 0x3F, 0x5A, 0x4A, 0x62, 0x66, 0x58, 0x3B, 0x4D, 0x66, 0x58, 0x5B, 0x5D, 0x4E, 0x6C, 0x49, 0x58, 0x3B, 0x4D, 0x66, 0x58, 0x3B, 0x4D, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64, 0x55, 0x6A, 0x32, 0x3E, 0x44, 0x45, 0x52, 0x6E, 0x3C, 0x31, 0x64, 0x55, 0x6A, 0x52, 0x4E, 0x6C, 0x69, 0x48, 0x53, 0x61, 0x4C, 0x39, 0x30, 0x6F, 0x47, 0x63, 0x59, 0x60, 0x57, 0x5B, 0x3D, 0x3E,
0x6F, 0x67, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x47, 0x63, 0x39, 0x50, 0x64, 0x35, 0x3A, 0x3A, 0x5A, 0x6A, 0x52, 0x4E, 0x6C, 0x69, 0x48, 0x53, 0x61, 0x6C, 0x49, 0x58, 0x3B, 0x4D, 0x46, 0x68, 0x63, 0x39, 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x67, 0x53, 0x41, 0x25, 0x41, 0x3C, 0x51, 0x54, 0x3D, 0x5E, 0x54, 0x5D, 0x4E, 0x4C, 0x39, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x6E, 0x3C, 0x31, 0x64, 0x35, 0x5A, 0x00, 0x00};
0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x31, 0x64,
0x35, 0x5A, 0x4A, 0x42, 0x56, 0x40, 0x67, 0x53, 0x41, 0x07, 0x6C,
0x49, 0x58, 0x3B, 0x4D, 0x46, 0x68, 0x43, 0x69, 0x48, 0x33, 0x31,
0x44, 0x65, 0x62, 0x46, 0x48, 0x53, 0x41, 0x07, 0x6C, 0x69, 0x48,
0x33, 0x51, 0x54, 0x5D, 0x4E, 0x6C, 0x49, 0x38, 0x4B, 0x55, 0x4A,
0x62, 0x46, 0x48, 0x33, 0x51, 0x34, 0x6D, 0x36, 0x50, 0x5F, 0x5F,
0x5F, 0x3F, 0x6F, 0x47, 0x63, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64,
0x35, 0x5A, 0x6A, 0x52, 0x6E, 0x3C, 0x51, 0x34, 0x6D, 0x36, 0x50,
0x5F, 0x5F, 0x3F, 0x4F, 0x37, 0x4B, 0x35, 0x5A, 0x4A, 0x62, 0x66,
0x58, 0x3B, 0x4D, 0x66, 0x58, 0x5B, 0x5D, 0x4E, 0x6C, 0x49, 0x58,
0x3B, 0x4D, 0x66, 0x58, 0x3B, 0x4D, 0x46, 0x48, 0x53, 0x61, 0x4C,
0x59, 0x40, 0x67, 0x33, 0x31, 0x64, 0x55, 0x6A, 0x32, 0x3E, 0x44,
0x45, 0x52, 0x6E, 0x3C, 0x31, 0x64, 0x55, 0x6A, 0x52, 0x4E, 0x6C,
0x69, 0x48, 0x53, 0x61, 0x4C, 0x39, 0x30, 0x6F, 0x47, 0x63, 0x59,
0x60, 0x57, 0x5B, 0x3D, 0x3E, 0x64, 0x35, 0x3A, 0x3A, 0x5A, 0x6A,
0x52, 0x4E, 0x6C, 0x69, 0x48, 0x53, 0x61, 0x6C, 0x49, 0x58, 0x3B,
0x4D, 0x46, 0x68, 0x63, 0x39, 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x67,
0x53, 0x41, 0x25, 0x41, 0x3C, 0x51, 0x54, 0x3D, 0x5E, 0x54, 0x5D,
0x4E, 0x4C, 0x39, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43,
0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x6E, 0x3C, 0x31, 0x64, 0x35,
0x5A, 0x00, 0x00
};
void fix_packet(char *buf, int32_t len) { void fix_packet(char *buf, int32_t len) {
unsigned long c1, c2; unsigned long c1, c2;
@ -141,7 +119,7 @@ int32_t icq_ack(int32_t s, char *login) {
return (hydra_send(s, buf, 10, 0)); return (hydra_send(s, buf, 10, 0));
} }
int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *miscptr, FILE * fp) { int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE *output, char *miscptr, FILE *fp) {
unsigned char buf[1024]; unsigned char buf[1024];
char *login, *pass; char *login, *pass;
char *empty = ""; char *empty = "";
@ -153,7 +131,7 @@ int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *mis
pass = empty; pass = empty;
for (i = 0; login[i]; i++) for (i = 0; login[i]; i++)
if (!isdigit((int32_t) login[i])) { if (!isdigit((int32_t)login[i])) {
fprintf(stderr, "[ERROR] Invalid UIN %s\n, ignoring.", login); fprintf(stderr, "[ERROR] Invalid UIN %s\n, ignoring.", login);
hydra_completed_pair(); hydra_completed_pair();
return 2; return 2;
@ -162,13 +140,13 @@ int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *mis
icq_login(sock, login, pass); icq_login(sock, login, pass);
while (1) { while (1) {
if ((r = hydra_recv(sock, (char *) buf, sizeof(buf))) == 0) { if ((r = hydra_recv(sock, (char *)buf, sizeof(buf))) == 0) {
return 1; return 1;
} }
if (r < 0) { if (r < 0) {
if (verbose) if (verbose)
fprintf(stderr, "[ERROR] Process %d: Can not connect [unreachable]\n", (int32_t) getpid()); fprintf(stderr, "[ERROR] Process %d: Can not connect [unreachable]\n", (int32_t)getpid());
return 3; return 3;
} }
@ -177,9 +155,9 @@ int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *mis
hydra_completed_pair_found(); hydra_completed_pair_found();
icq_ack(sock, login); icq_ack(sock, login);
icq_login_1(sock, login); icq_login_1(sock, login);
hydra_recv(sock, (char *) buf, sizeof(buf)); hydra_recv(sock, (char *)buf, sizeof(buf));
icq_ack(sock, login); icq_ack(sock, login);
hydra_recv(sock, (char *) buf, sizeof(buf)); hydra_recv(sock, (char *)buf, sizeof(buf));
icq_ack(sock, login); icq_ack(sock, login);
icq_disconnect(sock, login); icq_disconnect(sock, login);
break; break;
@ -188,7 +166,8 @@ int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *mis
break; break;
} }
/* if((buf[2] != 10 || buf[3] != 0) && (buf[2] != 250 || buf[3] != 0)) */ /* if((buf[2] != 10 || buf[3] != 0) && (buf[2] != 250 || buf[3] != 0))
*/
} }
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
@ -196,7 +175,7 @@ int32_t start_icq(int32_t sock, char *ip, int32_t port, FILE * output, char *mis
return 1; return 1;
} }
void service_icq(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_icq(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ICQ; int32_t myport = PORT_ICQ;
@ -221,7 +200,8 @@ void service_icq(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
sock = hydra_connect_udp(ip, myport); sock = hydra_connect_udp(ip, myport);
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
@ -233,21 +213,23 @@ void service_icq(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
break;
default: default:
fprintf(stderr, "[ERROR] Caught unknown return code, exiting!\n"); fprintf(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
break;
} }
run = next_run; run = next_run;
} }
} }
int32_t service_icq_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_icq_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -20,7 +20,8 @@ char *imap_read_server_capacity(int32_t sock) {
if (strstr(buf, "CAPABILITY") != NULL && buf[0] == '*') { if (strstr(buf, "CAPABILITY") != NULL && buf[0] == '*') {
resp = 1; resp = 1;
usleepn(300); usleepn(300);
/* we got the capability info then get the completed warning info from server */ /* we got the capability info then get the completed warning info from
* server */
while (hydra_data_ready(sock)) { while (hydra_data_ready(sock)) {
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
@ -30,7 +31,7 @@ char *imap_read_server_capacity(int32_t sock) {
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r') if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (isdigit((int32_t) *ptr) && *(ptr + 1) == ' ') { if (isdigit((int32_t)*ptr) && *(ptr + 1) == ' ') {
resp = 1; resp = 1;
} }
} }
@ -39,8 +40,8 @@ char *imap_read_server_capacity(int32_t sock) {
return buf; return buf;
} }
int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "", *result = NULL;
char *login, *pass, buffer[500], buffer2[500], *fooptr; char *login, *pass, buffer[500], buffer2[500], *fooptr;
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
@ -69,7 +70,7 @@ int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
free(buf); free(buf);
strcpy(buffer2, login); strcpy(buffer2, login);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -84,7 +85,7 @@ int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
free(buf); free(buf);
strcpy(buffer2, pass); strcpy(buffer2, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
break; break;
@ -103,227 +104,227 @@ int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, cha
free(buf); free(buf);
memset(buffer2, 0, sizeof(buffer2)); memset(buffer2, 0, sizeof(buffer2));
sasl_plain(buffer2, login, pass); result = sasl_plain(buffer2, login, pass);
if (result == NULL)
return 3;
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
break; break;
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_CRAMMD5: case AUTH_CRAMMD5:
case AUTH_CRAMSHA1: case AUTH_CRAMSHA1:
case AUTH_CRAMSHA256:{ case AUTH_CRAMSHA256: {
int32_t rc = 0; int32_t rc = 0;
char *preplogin; char *preplogin;
rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin); rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) { if (rc) {
return 3; return 3;
} }
switch (imap_auth_mechanism) {
case AUTH_CRAMMD5:
sprintf(buffer, "%d AUTHENTICATE CRAM-MD5\r\n", counter);
break;
case AUTH_CRAMSHA1:
sprintf(buffer, "%d AUTHENTICATE CRAM-SHA1\r\n", counter);
break;
case AUTH_CRAMSHA256:
sprintf(buffer, "%d AUTHENTICATE CRAM-SHA256\r\n", counter);
break;
}
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
// get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
switch (imap_auth_mechanism) { switch (imap_auth_mechanism) {
case AUTH_CRAMMD5: case AUTH_CRAMMD5:
sprintf(buffer, "%d AUTHENTICATE CRAM-MD5\r\n", counter); hydra_report(stderr, "[ERROR] IMAP CRAM-MD5 AUTH : %s\n", buf);
break; break;
case AUTH_CRAMSHA1: case AUTH_CRAMSHA1:
sprintf(buffer, "%d AUTHENTICATE CRAM-SHA1\r\n", counter); hydra_report(stderr, "[ERROR] IMAP CRAM-SHA1 AUTH : %s\n", buf);
break; break;
case AUTH_CRAMSHA256: case AUTH_CRAMSHA256:
sprintf(buffer, "%d AUTHENTICATE CRAM-SHA256\r\n", counter); hydra_report(stderr, "[ERROR] IMAP CRAM-SHA256 AUTH : %s\n", buf);
break; break;
} }
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
//get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
switch (imap_auth_mechanism) {
case AUTH_CRAMMD5:
hydra_report(stderr, "[ERROR] IMAP CRAM-MD5 AUTH : %s\n", buf);
break;
case AUTH_CRAMSHA1:
hydra_report(stderr, "[ERROR] IMAP CRAM-SHA1 AUTH : %s\n", buf);
break;
case AUTH_CRAMSHA256:
hydra_report(stderr, "[ERROR] IMAP CRAM-SHA256 AUTH : %s\n", buf);
break;
}
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 2);
free(buf); free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf + 2);
free(buf);
memset(buffer2, 0, sizeof(buffer2));
switch (imap_auth_mechanism) {
case AUTH_CRAMMD5: {
result = sasl_cram_md5(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
} break;
case AUTH_CRAMSHA1: {
result = sasl_cram_sha1(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
} break;
case AUTH_CRAMSHA256: {
result = sasl_cram_sha256(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
} break;
}
hydra_tobase64((unsigned char *)buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} break;
case AUTH_DIGESTMD5: {
sprintf(buffer, "%d AUTHENTICATE DIGEST-MD5\r\n", counter);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
// receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
hydra_report(stderr, "[ERROR] IMAP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2;
result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "imap", NULL, 0, NULL);
if (result == NULL)
return 3;
if (debug)
hydra_report(stderr, "DEBUG C: %s\n", buffer2);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} break;
case AUTH_SCRAMSHA1: {
char clientfirstmessagebare[200];
char serverfirstmessage[200];
char *preplogin;
int32_t rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) {
return 3;
}
sprintf(buffer, "%d AUTHENTICATE SCRAM-SHA-1\r\n", counter);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
hydra_report(stderr, "[ERROR] IMAP SCRAM-SHA1 AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
snprintf(clientfirstmessagebare, sizeof(clientfirstmessagebare), "n=%s,r=hydra", preplogin);
free(preplogin);
memset(buffer2, 0, sizeof(buffer2));
sprintf(buffer2, "n,,%.200s", clientfirstmessagebare);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
snprintf(buffer, sizeof(buffer), "%s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
buf = hydra_receive_line(s);
if (buf == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Not a valid server challenge\n");
free(buf);
return 1;
} else {
/* recover server challenge */
memset(buffer, 0, sizeof(buffer));
//+ cj1oeWRyYU9VNVZqcHQ5RjNqcmVXRVFWTCxzPWhGbTNnRGw0akdidzJVVHosaT00MDk2
from64tobits((char *)buffer, buf + 2);
free(buf);
strncpy(serverfirstmessage, buffer, sizeof(serverfirstmessage) - 1);
serverfirstmessage[sizeof(serverfirstmessage) - 1] = '\0';
memset(buffer2, 0, sizeof(buffer2)); memset(buffer2, 0, sizeof(buffer2));
switch (imap_auth_mechanism) {
case AUTH_CRAMMD5:{
sasl_cram_md5(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
case AUTH_CRAMSHA1:{
sasl_cram_sha1(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
case AUTH_CRAMSHA256:{
sasl_cram_sha256(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
}
hydra_tobase64((unsigned char *) buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
}
break;
case AUTH_DIGESTMD5:{
sprintf(buffer, "%d AUTHENTICATE DIGEST-MD5\r\n", counter);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
//receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
hydra_report(stderr, "[ERROR] IMAP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2; fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "imap", NULL, 0, NULL); result = sasl_scram_sha1(fooptr, pass, clientfirstmessagebare, serverfirstmessage);
if (fooptr == NULL) if (result == NULL) {
return 3; hydra_report(stderr, "[ERROR] Can't compute client response\n");
if (debug) return 1;
hydra_report(stderr, "DEBUG C: %s\n", buffer2); }
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2); sprintf(buffer, "%s\r\n", buffer2);
} }
break; } break;
case AUTH_SCRAMSHA1:{
char clientfirstmessagebare[200];
char serverfirstmessage[200];
char *preplogin;
int32_t rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) {
return 3;
}
sprintf(buffer, "%d AUTHENTICATE SCRAM-SHA-1\r\n", counter);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
hydra_report(stderr, "[ERROR] IMAP SCRAM-SHA1 AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
snprintf(clientfirstmessagebare, sizeof(clientfirstmessagebare), "n=%s,r=hydra", preplogin);
free(preplogin);
memset(buffer2, 0, sizeof(buffer2));
sprintf(buffer2, "n,,%.200s", clientfirstmessagebare);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
snprintf(buffer, sizeof(buffer), "%s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
buf = hydra_receive_line(s);
if (buf == NULL)
return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Not a valid server challenge\n");
free(buf);
return 1;
} else {
/* recover server challenge */
memset(buffer, 0, sizeof(buffer));
//+ cj1oeWRyYU9VNVZqcHQ5RjNqcmVXRVFWTCxzPWhGbTNnRGw0akdidzJVVHosaT00MDk2
from64tobits((char *) buffer, buf + 2);
free(buf);
strncpy(serverfirstmessage, buffer, sizeof(serverfirstmessage) - 1);
serverfirstmessage[sizeof(serverfirstmessage) - 1] = '\0';
memset(buffer2, 0, sizeof(buffer2));
fooptr = buffer2;
sasl_scram_sha1(fooptr, pass, clientfirstmessagebare, serverfirstmessage);
if (fooptr == NULL) {
hydra_report(stderr, "[ERROR] Can't compute client response\n");
return 1;
}
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
}
}
break;
#endif #endif
case AUTH_NTLM:{ case AUTH_NTLM: {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
//Send auth request // Send auth request
sprintf(buffer, "%d AUTHENTICATE NTLM\r\n", counter); sprintf(buffer, "%d AUTHENTICATE NTLM\r\n", counter);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1; return 1;
//receive // receive
if ((buf = hydra_receive_line(s)) == NULL) if ((buf = hydra_receive_line(s)) == NULL)
return 1; return 1;
if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) { if (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL || strstr(buf, "BYE") != NULL) {
hydra_report(stderr, "[ERROR] IMAP NTLM AUTH : %s\n", buf); hydra_report(stderr, "[ERROR] IMAP NTLM AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf); free(buf);
//send auth and receive challenge return 3;
//send auth request: lst the server send it's own hostname and domainname
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2));
sprintf(buffer, "%s\r\n", buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strlen(buf) < 6) {
free(buf);
return 1;
}
//recover challenge
from64tobits((char *) buf1, buf + 2);
free(buf);
//Send response
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2));
sprintf(buffer, "%s\r\n", buf1);
} }
break; free(buf);
// send auth and receive challenge
// send auth request: lst the server send it's own hostname and domainname
buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
sprintf(buffer, "%s\r\n", buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strlen(buf) < 6) {
free(buf);
return 1;
}
// recover challenge
from64tobits((char *)buf1, buf + 2);
free(buf);
// Send response
buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "%s\r\n", buf1);
} break;
default: default:
//clear authentication // clear authentication
sprintf(buffer, "%d LOGIN \"%.100s\" \"%.100s\"\r\n", counter, login, pass); sprintf(buffer, "%d LOGIN \"%.100s\" \"%.100s\"\r\n", counter, login, pass);
} }
@ -353,7 +354,7 @@ int32_t start_imap(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 1; return 1;
} }
void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_IMAP, mysslport = PORT_IMAP_SSL, disable_tls = 1; int32_t myport = PORT_IMAP, mysslport = PORT_IMAP_SSL, disable_tls = 1;
char *buffer1 = "1 CAPABILITY\r\n"; char *buffer1 = "1 CAPABILITY\r\n";
@ -363,10 +364,10 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -380,12 +381,12 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if ((buf == NULL) || (strstr(buf, "OK") == NULL && buf[0] != '*')) { /* check the first line */ if ((buf == NULL) || (strstr(buf, "OK") == NULL && buf[0] != '*')) { /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an IMAP protocol or service shutdown:\n"); hydra_report(stderr, "[ERROR] Not an IMAP protocol or service shutdown:\n");
if (buf != NULL) if (buf != NULL)
@ -407,7 +408,7 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
int32_t i; int32_t i;
for (i = 0; i < strlen(miscptr); i++) for (i = 0; i < strlen(miscptr); i++)
miscptr[i] = (char) toupper((int32_t) miscptr[i]); miscptr[i] = (char)toupper((int32_t)miscptr[i]);
if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) { if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) {
disable_tls = 0; disable_tls = 0;
@ -415,14 +416,16 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (!disable_tls) { if (!disable_tls) {
/* check for STARTTLS, if available we may have access to more basic auth methods */ /* check for STARTTLS, if available we may have access to more basic
* auth methods */
if (strstr(buf, "STARTTLS") != NULL) { if (strstr(buf, "STARTTLS") != NULL) {
hydra_send(sock, "2 STARTTLS\r\n", strlen("2 STARTTLS\r\n"), 0); hydra_send(sock, "2 STARTTLS\r\n", strlen("2 STARTTLS\r\n"), 0);
counter++; counter++;
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL)) { if (buf == NULL || (strstr(buf, " NO ") != NULL || strstr(buf, "failed") != NULL || strstr(buf, " BAD ") != NULL)) {
hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer received from STARTTLS request\n"); hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer "
"received from STARTTLS request\n");
} else { } else {
free(buf); free(buf);
if ((hydra_connect_to_ssl(sock, hostname) == -1)) { if ((hydra_connect_to_ssl(sock, hostname) == -1)) {
@ -444,15 +447,16 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
hydra_child_exit(2); hydra_child_exit(2);
} }
} else } else
hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is not supported by the server\n"); hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is "
"not supported by the server\n");
} }
#endif #endif
if (verbose) if (verbose)
hydra_report(stderr, "[VERBOSE] CAPABILITY: %s", buf); hydra_report(stderr, "[VERBOSE] CAPABILITY: %s", buf);
//authentication should be listed AUTH= like in the extract below // authentication should be listed AUTH= like in the extract below
//STARTTLS LOGINDISABLED AUTH=GSSAPI AUTH=DIGEST-MD5 AUTH=CRAM-MD5 // STARTTLS LOGINDISABLED AUTH=GSSAPI AUTH=DIGEST-MD5 AUTH=CRAM-MD5
if ((strstr(buf, "=LOGIN") == NULL) && (strstr(buf, "=NTLM") != NULL)) { if ((strstr(buf, "=LOGIN") == NULL) && (strstr(buf, "=NTLM") != NULL)) {
imap_auth_mechanism = AUTH_NTLM; imap_auth_mechanism = AUTH_NTLM;
} }
@ -487,7 +491,6 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
free(buf); free(buf);
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
if (strstr(miscptr, "CLEAR")) if (strstr(miscptr, "CLEAR"))
imap_auth_mechanism = AUTH_CLEAR; imap_auth_mechanism = AUTH_CLEAR;
@ -554,11 +557,11 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_imap(sock, ip, port, options, miscptr, fp); next_run = start_imap(sock, ip, port, options, miscptr, fp);
counter++; counter++;
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -571,13 +574,13 @@ void service_imap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
int32_t service_imap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_imap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -585,8 +588,11 @@ int32_t service_imap_init(char *ip, int32_t sp, unsigned char options, char *mis
return 0; return 0;
} }
void usage_imap(const char* service) { void usage_imap(const char *service) {
printf("Module imap is optionally taking one authentication type of:\n" printf("Module imap is optionally taking one authentication type of:\n"
" CLEAR or APOP (default), LOGIN, PLAIN, CRAM-MD5, CRAM-SHA1,\n" " CLEAR or APOP (default), LOGIN, PLAIN, CRAM-MD5, CRAM-SHA1,\n"
" CRAM-SHA256, DIGEST-MD5, NTLM\n" "Additionally TLS encryption via STARTTLS can be enforced with the TLS option.\n\n" "Example: imap://target/TLS:PLAIN\n"); " CRAM-SHA256, DIGEST-MD5, NTLM\n"
"Additionally TLS encryption via STARTTLS can be enforced with the "
"TLS option.\n\n"
"Example: imap://target/TLS:PLAIN\n");
} }

View file

@ -7,11 +7,10 @@ RFC 1459: Internet Relay Chat Protocol
*/ */
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
char buffer[300] = ""; char buffer[300] = "";
int32_t myport = PORT_IRC, mysslport = PORT_IRC_SSL; int32_t myport = PORT_IRC, mysslport = PORT_IRC_SSL;
int32_t start_oper_irc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_oper_irc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
int32_t ret; int32_t ret;
@ -53,7 +52,7 @@ int32_t send_nick(int32_t s, char *ip, char *pass) {
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return -1; return -1;
} }
sprintf(buffer, "NICK hydra%d\r\nUSER hydra%d hydra %s :hydra\r\n", (int32_t) getpid(), (int32_t) getpid(), hydra_address2string(ip)); sprintf(buffer, "NICK hydra%d\r\nUSER hydra%d hydra %s :hydra\r\n", (int32_t)getpid(), (int32_t)getpid(), hydra_address2string(ip));
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return -1; return -1;
} }
@ -63,7 +62,7 @@ int32_t send_nick(int32_t s, char *ip, char *pass) {
int32_t irc_server_connect(char *ip, int32_t sock, int32_t port, unsigned char options, char *hostname) { int32_t irc_server_connect(char *ip, int32_t sock, int32_t port, unsigned char options, char *hostname) {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -78,7 +77,7 @@ int32_t irc_server_connect(char *ip, int32_t sock, int32_t port, unsigned char o
return sock; return sock;
} }
int32_t start_pass_irc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *hostname) { int32_t start_pass_irc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp, char *hostname) {
char *empty = ""; char *empty = "";
char *pass; char *pass;
int32_t ret; int32_t ret;
@ -88,7 +87,7 @@ int32_t start_pass_irc(int32_t s, char *ip, int32_t port, unsigned char options,
s = irc_server_connect(ip, s, port, options, hostname); s = irc_server_connect(ip, s, port, options, hostname);
if (s < 0) { if (s < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
return 3; return 3;
} }
@ -106,10 +105,16 @@ int32_t start_pass_irc(int32_t s, char *ip, int32_t port, unsigned char options,
#endif #endif
hydra_report_pass_found(port, ip, "irc", fp); hydra_report_pass_found(port, ip, "irc", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
hydra_report(stderr, "[INFO] Server password '%s' is working, you can pass it as argument\nto irc module to then try login/password oper mode\n", pass); hydra_report(stderr,
"[INFO] Server password '%s' is working, you can pass it as "
"argument\nto irc module to then try login/password oper mode\n",
pass);
} else { } else {
if (verbose && (miscptr != NULL)) if (verbose && (miscptr != NULL))
hydra_report(stderr, "[VERBOSE] Server is requesting a general password, '%s' you entered is not working\n", miscptr); hydra_report(stderr,
"[VERBOSE] Server is requesting a general password, '%s' "
"you entered is not working\n",
miscptr);
hydra_completed_pair(); hydra_completed_pair();
} }
@ -118,7 +123,7 @@ int32_t start_pass_irc(int32_t s, char *ip, int32_t port, unsigned char options,
return 4; return 4;
} }
void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1, ret; int32_t run = 1, next_run = 1, sock = -1, ret;
char *buf; char *buf;
@ -129,11 +134,11 @@ void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
sock = irc_server_connect(ip, sock, port, options, hostname); sock = irc_server_connect(ip, sock, port, options, hostname);
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -148,7 +153,7 @@ void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
if ((ret = hydra_recv(sock, buffer, sizeof(buffer) - 1)) >= 0) if ((ret = hydra_recv(sock, buffer, sizeof(buffer) - 1)) >= 0)
buffer[ret] = 0; buffer[ret] = 0;
/* ERROR :Bad password */ /* ERROR :Bad password */
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if ((ret > 0) && (hydra_string_match(buffer, "ERROR\\s.*password"))) { if ((ret > 0) && (hydra_string_match(buffer, "ERROR\\s.*password"))) {
#else #else
@ -181,19 +186,23 @@ void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
hydra_child_exit(0); hydra_child_exit(0);
} }
/* ERROR :Bad password is returned from ngircd when it s waiting for a server password */ /* ERROR :Bad password is returned from ngircd when it s waiting for a
* server password */
if ((ret > 0) && (strstr(buffer, " 001 ") == NULL)) { if ((ret > 0) && (strstr(buffer, " 001 ") == NULL)) {
/* seems we not successfully connected */ /* seems we not successfully connected */
hydra_report(stderr, "[ERROR] should not be able to identify server msg, please report it\n%s\n", buffer); hydra_report(stderr,
"[ERROR] should not be able to identify server msg, "
"please report it\n%s\n",
buffer);
hydra_child_exit(0); hydra_child_exit(0);
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_oper_irc(sock, ip, port, options, miscptr, fp); next_run = start_oper_irc(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -209,13 +218,13 @@ void service_irc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
} }
int32_t service_irc_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_irc_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -223,6 +232,8 @@ int32_t service_irc_init(char *ip, int32_t sp, unsigned char options, char *misc
return 0; return 0;
} }
void usage_irc(const char* service) { void usage_irc(const char *service) {
printf("Module irc is optionally taking the general server password, if the server is requiring one, and if none is passed the password from -p/-P will be used\n\n"); printf("Module irc is optionally taking the general server password, if the "
"server is requiring one, and if none is passed the password from "
"-p/-P will be used\n\n");
} }

View file

@ -7,8 +7,8 @@ unsigned char *buf;
int32_t counter; int32_t counter;
int32_t tls_required = 0; int32_t tls_required = 0;
int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *hostname, char version, int32_t auth_method) { int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp, char *hostname, char version, int32_t auth_method) {
char *empty = ""; char *empty = "", *result = NULL;
char *login = "", *pass, *fooptr = ""; char *login = "", *pass, *fooptr = "";
unsigned char buffer[512]; unsigned char buffer[512];
int32_t length = 0; int32_t length = 0;
@ -18,7 +18,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
The LDAP "simple" method has three modes of operation: The LDAP "simple" method has three modes of operation:
* anonymous= no user no pass * anonymous= no user no pass
* unauthenticated= user but no pass * unauthenticated= user but no pass
* user/password authenticated= user and pass * user/password authenticated= user and pass
*/ */
if ((miscptr != NULL) && (ldap_auth_mechanism == AUTH_CLEAR)) { if ((miscptr != NULL) && (ldap_auth_mechanism == AUTH_CLEAR)) {
@ -65,9 +65,9 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
if (ldap_auth_mechanism == AUTH_CLEAR) { if (ldap_auth_mechanism == AUTH_CLEAR) {
buffer[11] = strlen(login); /* DN */ buffer[11] = strlen(login); /* DN */
memcpy(&buffer[12], login, strlen(login)); memcpy(&buffer[12], login, strlen(login));
buffer[12 + strlen(login)] = (unsigned char) 128; buffer[12 + strlen(login)] = (unsigned char)128;
buffer[13 + strlen(login)] = strlen(pass); buffer[13 + strlen(login)] = strlen(pass);
memcpy(&buffer[14 + strlen(login)], pass, strlen(pass)); /* PASS */ memcpy(&buffer[14 + strlen(login)], pass, strlen(pass)); /* PASS */
} else { } else {
char *authm = "DIGEST-MD5"; char *authm = "DIGEST-MD5";
@ -79,7 +79,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
miscptr[sizeof(buffer) - 16 - strlen(authm)] = '\0'; miscptr[sizeof(buffer) - 16 - strlen(authm)] = '\0';
} }
buffer[11] = strlen(miscptr); /* DN */ buffer[11] = strlen(miscptr); /* DN */
memcpy(&buffer[12], miscptr, strlen(miscptr)); memcpy(&buffer[12], miscptr, strlen(miscptr));
buffer[12 + strlen(miscptr)] = 163; buffer[12 + strlen(miscptr)] = 163;
buffer[13 + strlen(miscptr)] = 2 + strlen(authm); buffer[13 + strlen(miscptr)] = 2 + strlen(authm);
@ -87,9 +87,9 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
buffer[15 + strlen(miscptr)] = strlen(authm); buffer[15 + strlen(miscptr)] = strlen(authm);
memcpy(&buffer[16 + strlen(miscptr)], authm, strlen(authm)); memcpy(&buffer[16 + strlen(miscptr)], authm, strlen(authm));
} }
if (hydra_send(s, (char *) buffer, length, 0) < 0) if (hydra_send(s, (char *)buffer, length, 0) < 0)
return 1; return 1;
if ((buf = (unsigned char *) hydra_receive_line(s)) == NULL) if ((buf = (unsigned char *)hydra_receive_line(s)) == NULL)
return 1; return 1;
if (buf[0] != 0 && buf[0] != 32 && buf[9] == 2) { if (buf[0] != 0 && buf[0] != 32 && buf[9] == 2) {
@ -115,16 +115,16 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
/* one more step auth for CRAM and DIGEST */ /* one more step auth for CRAM and DIGEST */
if (ldap_auth_mechanism == AUTH_CRAMMD5) { if (ldap_auth_mechanism == AUTH_CRAMMD5) {
/* get the challenge, need to extract it */ /* get the challenge, need to extract it */
char *ptr; char *ptr;
char buf2[32]; char buf2[32];
ptr = strstr((char *) buf, "<"); ptr = strstr((char *)buf, "<");
fooptr = buf2; fooptr = buf2;
sasl_cram_md5(fooptr, pass, ptr); result = sasl_cram_md5(fooptr, pass, ptr);
if (fooptr == NULL) if (result == NULL)
return 1; return 1;
counter++; counter++;
if (strstr(miscptr, "^USER^") != NULL) { if (strstr(miscptr, "^USER^") != NULL) {
@ -148,7 +148,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
buffer[9] = version; buffer[9] = version;
buffer[10] = 4; buffer[10] = 4;
buffer[11] = strlen(miscptr); /* DN */ buffer[11] = strlen(miscptr); /* DN */
memcpy(&buffer[12], miscptr, strlen(miscptr)); memcpy(&buffer[12], miscptr, strlen(miscptr));
buffer[12 + strlen(miscptr)] = 163; buffer[12 + strlen(miscptr)] = 163;
buffer[13 + strlen(miscptr)] = 2 + strlen("CRAM-MD5") + 2 + strlen(login) + 1 + strlen(buf2); buffer[13 + strlen(miscptr)] = 2 + strlen("CRAM-MD5") + 2 + strlen(login) + 1 + strlen(buf2);
@ -161,10 +161,10 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
buffer[18 + strlen(miscptr) + strlen("CRAM-MD5") + strlen(login)] = ' '; buffer[18 + strlen(miscptr) + strlen("CRAM-MD5") + strlen(login)] = ' ';
memcpy(&buffer[18 + strlen(miscptr) + strlen("CRAM-MD5") + strlen(login) + 1], buf2, strlen(buf2)); memcpy(&buffer[18 + strlen(miscptr) + strlen("CRAM-MD5") + strlen(login) + 1], buf2, strlen(buf2));
if (hydra_send(s, (char *) buffer, length, 0) < 0) if (hydra_send(s, (char *)buffer, length, 0) < 0)
return 1; return 1;
free(buf); free(buf);
if ((buf = (unsigned char *) hydra_receive_line(s)) == NULL) if ((buf = (unsigned char *)hydra_receive_line(s)) == NULL)
return 1; return 1;
} else { } else {
if (ldap_auth_mechanism == AUTH_DIGESTMD5) { if (ldap_auth_mechanism == AUTH_DIGESTMD5) {
@ -172,7 +172,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
char buffer2[500]; char buffer2[500];
int32_t ind = 0; int32_t ind = 0;
ptr = strstr((char *) buf, "realm="); ptr = strstr((char *)buf, "realm=");
counter++; counter++;
if (strstr(miscptr, "^USER^") != NULL) { if (strstr(miscptr, "^USER^") != NULL) {
@ -180,8 +180,8 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
fooptr = buffer2; fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, ptr, miscptr, "ldap", NULL, 0, NULL); result = sasl_digest_md5(fooptr, login, pass, ptr, miscptr, "ldap", NULL, 0, NULL);
if (fooptr == NULL) { if (result == NULL) {
free(buf); free(buf);
return 3; return 3;
} }
@ -213,7 +213,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
ind++; ind++;
buffer[ind] = counter % 256; buffer[ind] = counter % 256;
ind++; ind++;
buffer[ind] = 96; /*0x60 */ buffer[ind] = 96; /*0x60 */
ind++; ind++;
buffer[ind] = 130; buffer[ind] = 130;
ind++; ind++;
@ -240,9 +240,9 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
buffer[ind] = strlen(miscptr); buffer[ind] = strlen(miscptr);
ind++; ind++;
memcpy(&buffer[ind], miscptr, strlen(miscptr)); memcpy(&buffer[ind], miscptr, strlen(miscptr));
/*DN*/ buffer[ind + strlen(miscptr)] = 163; //0xa3 /*DN*/ buffer[ind + strlen(miscptr)] = 163; // 0xa3
ind++; ind++;
buffer[ind + strlen(miscptr)] = 130; //0x82 buffer[ind + strlen(miscptr)] = 130; // 0x82
ind++; ind++;
if (strlen(buffer2) + 6 + strlen("DIGEST-MD5") > 255) { if (strlen(buffer2) + 6 + strlen("DIGEST-MD5") > 255) {
@ -279,10 +279,10 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
memcpy(&buffer[ind + strlen(miscptr) + strlen("DIGEST-MD5")], buffer2, strlen(buffer2)); memcpy(&buffer[ind + strlen(miscptr) + strlen("DIGEST-MD5")], buffer2, strlen(buffer2));
ind++; ind++;
if (hydra_send(s, (char *) buffer, length, 0) < 0) if (hydra_send(s, (char *)buffer, length, 0) < 0)
return 1; return 1;
free(buf); free(buf);
if ((buf = (unsigned char *) hydra_receive_line(s)) == NULL) if ((buf = (unsigned char *)hydra_receive_line(s)) == NULL)
return 1; return 1;
} }
} }
@ -306,21 +306,27 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
if ((buf[0] != 0 && buf[0] != 32) && buf[9] == 53) { if ((buf[0] != 0 && buf[0] != 32) && buf[9] == 53) {
if (verbose) if (verbose)
hydra_report(stderr, "[VERBOSE] Server unwilling to perform action, maybe deny by server config or too busy when tried login: %s password: %s\n", login, pass); hydra_report(stderr,
"[VERBOSE] Server unwilling to perform action, maybe deny by server "
"config or too busy when tried login: %s password: %s\n",
login, pass);
free(buf); free(buf);
return 1; return 1;
} }
if ((buf[0] != 0 && buf[0] != 32) && buf[9] == 2) { if ((buf[0] != 0 && buf[0] != 32) && buf[9] == 2) {
hydra_report(stderr, "[ERROR] Invalid protocol version, you tried ldap%c, better try ldap%c\n", version + '0', version == 2 ? '3' : '2'); hydra_report(stderr,
"[ERROR] Invalid protocol version, you tried ldap%c, better "
"try ldap%c\n",
version + '0', version == 2 ? '3' : '2');
free(buf); free(buf);
hydra_child_exit(2); hydra_child_exit(2);
sleep(1); sleep(1);
hydra_child_exit(2); hydra_child_exit(2);
} }
//0 0x30, 0x84, 0x20, 0x20, 0x20, 0x10, 0x02, 0x01, // 0 0x30, 0x84, 0x20, 0x20, 0x20, 0x10, 0x02, 0x01,
//8 0x01, 0x61, 0x84, 0x20, 0x20, 0x20, 0x07, 0x0a, // 8 0x01, 0x61, 0x84, 0x20, 0x20, 0x20, 0x07, 0x0a,
//16 0x01, 0x20, 0x04, 0x20, 0x04, 0x20, 0x00, 0x00, // 16 0x01, 0x20, 0x04, 0x20, 0x04, 0x20, 0x00, 0x00,
// this is for w2k8 active directory ldap auth // this is for w2k8 active directory ldap auth
if (buf[0] == 48 && buf[1] == 132) { if (buf[0] == 48 && buf[1] == 132) {
@ -335,10 +341,9 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
} }
} else { } else {
if (buf[9] != 49 && buf[9] != 2 && buf[9] != 53) { if (buf[9] != 49 && buf[9] != 2 && buf[9] != 53) {
hydra_report(stderr, "[ERROR] Uh, unknown LDAP response! Please report this: \n"); hydra_report(stderr, "[ERROR] Uh, unknown LDAP response! Please report this: \n");
print_hex((unsigned char *) buf, 24); print_hex((unsigned char *)buf, 24);
free(buf); free(buf);
return 3; return 3;
} }
@ -351,7 +356,7 @@ int32_t start_ldap(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 2; return 2;
} }
void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname, char version, int32_t auth_method) { void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname, char version, int32_t auth_method) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_LDAP, mysslport = PORT_LDAP_SSL; int32_t myport = PORT_LDAP, mysslport = PORT_LDAP_SSL;
@ -360,10 +365,10 @@ void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -377,22 +382,25 @@ void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
counter = 1; counter = 1;
if (tls_required) { if (tls_required) {
/* Start TLS operation OID = 1.3.6.1.4.1.1466.20037 according to RFC 2830 */ /* Start TLS operation OID = 1.3.6.1.4.1.1466.20037 according to RFC
char confidentiality_required[] = "\x30\x1d\x02\x01\x01\x77\x18\x80\x16\x31\x2e\x33\x2e\x36\x2e\x31\x2e\x34\x2e\x31\x2e\x31\x34\x36\x36\x2e\x32\x30\x30\x33\x37"; * 2830 */
char confidentiality_required[] = "\x30\x1d\x02\x01\x01\x77\x18\x80\x16\x31\x2e\x33\x2e\x36\x2e\x31"
"\x2e\x34\x2e\x31\x2e\x31\x34\x36\x36\x2e\x32\x30\x30\x33\x37";
if (hydra_send(sock, confidentiality_required, strlen(confidentiality_required), 0) < 0) if (hydra_send(sock, confidentiality_required, strlen(confidentiality_required), 0) < 0)
hydra_child_exit(1); hydra_child_exit(1);
if ((buf = (unsigned char *) hydra_receive_line(sock)) == NULL) if ((buf = (unsigned char *)hydra_receive_line(sock)) == NULL)
hydra_child_exit(1); hydra_child_exit(1);
if ((buf[0] != 0 && buf[9] == 0) || (buf[0] != 32 && buf[9] == 32)) { if ((buf[0] != 0 && buf[9] == 0) || (buf[0] != 32 && buf[9] == 32)) {
/* TLS option negociation goes well, now trying to connect */ /* TLS option negociation goes well, now trying to connect */
free(buf);
if ((hydra_connect_to_ssl(sock, hostname) == -1) && verbose) { if ((hydra_connect_to_ssl(sock, hostname) == -1) && verbose) {
hydra_report(stderr, "[ERROR] Can't use TLS\n"); hydra_report(stderr, "[ERROR] Can't use TLS\n");
hydra_child_exit(1); hydra_child_exit(1);
@ -403,16 +411,17 @@ void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} else { } else {
hydra_report(stderr, "[ERROR] Can't use TLS %s\n", buf); hydra_report(stderr, "[ERROR] Can't use TLS %s\n", buf);
free(buf);
hydra_child_exit(1); hydra_child_exit(1);
} }
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_ldap(sock, ip, port, options, miscptr, fp, hostname, version, auth_method); next_run = start_ldap(sock, ip, port, options, miscptr, fp, hostname, version, auth_method);
counter++; counter++;
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -425,47 +434,46 @@ void service_ldap(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
void service_ldap2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ldap2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ldap(ip, sp, options, miscptr, fp, port, hostname, 2, AUTH_CLEAR); }
service_ldap(ip, sp, options, miscptr, fp, port, hostname, 2, AUTH_CLEAR);
}
void service_ldap3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ldap3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_CLEAR); }
service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_CLEAR);
}
void service_ldap3_cram_md5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ldap3_cram_md5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_CRAMMD5); }
service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_CRAMMD5);
}
void service_ldap3_digest_md5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ldap3_digest_md5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_DIGESTMD5); }
service_ldap(ip, sp, options, miscptr, fp, port, hostname, 3, AUTH_DIGESTMD5);
}
int32_t service_ldap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_ldap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
if (miscptr != NULL && strlen(miscptr) > 220) { if (miscptr != NULL && strlen(miscptr) > 220) {
fprintf(stderr, "[ERROR] the option string to this module may not be larger than 220 bytes\n"); fprintf(stderr, "[ERROR] the option string to this module may not be "
"larger than 220 bytes\n");
return -1; return -1;
} }
return 0; return 0;
} }
void usage_ldap(const char* service) { void usage_ldap(const char *service) {
printf("Module %s is optionally taking the DN (depending of the auth method choosed\n" printf("Module %s is optionally taking the DN (depending of the auth method "
"Note: you can also specify the DN as login when Simple auth method is used).\n" "choosed\n"
"Note: you can also specify the DN as login when Simple auth method "
"is used).\n"
"The keyword \"^USER^\" is replaced with the login.\n" "The keyword \"^USER^\" is replaced with the login.\n"
"Special notes for Simple method has 3 operation modes: anonymous, (no user no pass),\n" "Special notes for Simple method has 3 operation modes: anonymous, "
"unauthenticated (user but no pass), user/pass authenticated (user and pass).\n" "(no user no pass),\n"
"unauthenticated (user but no pass), user/pass authenticated (user "
"and pass).\n"
"So don't forget to set empty string as user/pass to test all modes.\n" "So don't forget to set empty string as user/pass to test all modes.\n"
"Hint: to authenticate to a windows active directory ldap, this is usually\n" "Hint: to authenticate to a windows active directory ldap, this is "
" cn=^USER^,cn=users,dc=foo,dc=bar,dc=com for domain foo.bar.com\n\n", service); "usually\n"
" cn=^USER^,cn=users,dc=foo,dc=bar,dc=com for domain foo.bar.com\n\n",
service);
} }

179
hydra-memcached.c Normal file
View file

@ -0,0 +1,179 @@
// This plugin was written by <david dot maciejak at gmail D O T com>
// Tested on memcached 1.5.6-0ubuntu1
#ifdef LIBMCACHED
#include <libmemcached/memcached.h>
#endif
#include "hydra-mod.h"
#ifndef LIBMCACHED
void dummy_mcached() { printf("\n"); }
#else
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
int mcached_send_com_quit(int32_t sock) {
char *com_quit = "quit\r\n";
if (hydra_send(sock, com_quit, strlen(com_quit), 0) < 0)
return 1;
return 0;
}
int mcached_send_com_version(int32_t sock) {
char *com_version = "version\r\n";
if (hydra_send(sock, com_version, strlen(com_version), 0) < 0)
return 1;
return 0;
}
int32_t start_mcached(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "";
char *login, *pass;
memcached_server_st *servers = NULL;
memcached_return_t rc;
memcached_st *cache;
if (strlen(login = hydra_get_next_login()) == 0)
login = empty;
if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty;
cache = memcached_create(NULL);
rc = memcached_set_sasl_auth_data(cache, login, pass);
if (rc != MEMCACHED_SUCCESS) {
if (verbose)
hydra_report(stderr, "[ERROR] Couldn't setup SASL auth: %s\n", memcached_strerror(cache, rc));
memcached_free(cache);
return 3;
}
rc = memcached_behavior_set(cache, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
if (rc != MEMCACHED_SUCCESS) {
if (verbose)
hydra_report(stderr, "[ERROR] Couldn't use the binary protocol: %s\n", memcached_strerror(cache, rc));
memcached_destroy_sasl_auth_data(cache);
memcached_free(cache);
return 3;
}
rc = memcached_behavior_set(cache, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 10000);
if (rc != MEMCACHED_SUCCESS) {
if (verbose)
hydra_report(stderr, "[ERROR] Couldn't set the connect timeout: %s\n", memcached_strerror(cache, rc));
memcached_destroy_sasl_auth_data(cache);
memcached_free(cache);
return 3;
}
servers = memcached_server_list_append(servers, hydra_address2string(ip), port, &rc);
rc = memcached_server_push(cache, servers);
if (rc != MEMCACHED_SUCCESS) {
if (verbose)
hydra_report(stderr, "[ERROR] Couldn't add server: %s\n", memcached_strerror(cache, rc));
memcached_destroy_sasl_auth_data(cache);
memcached_free(cache);
return 3;
}
rc = memcached_stat_execute(cache, "", NULL, NULL);
if (rc != MEMCACHED_SUCCESS) {
if (verbose)
hydra_report(stderr, "[ERROR] Couldn't get server stats: %s\n", memcached_strerror(cache, rc));
memcached_destroy_sasl_auth_data(cache);
memcached_free(cache);
hydra_completed_pair_skip();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
return 3;
}
return 2;
}
memcached_destroy_sasl_auth_data(cache);
memcached_free(cache);
hydra_report_found_host(port, ip, "memcached", fp);
hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3;
return 2;
}
void service_mcached(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1;
hydra_register_socket(sp);
while (1) {
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return;
switch (run) {
case 1:
next_run = start_mcached(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
hydra_child_exit(0);
return;
default:
if (!verbose)
hydra_report(stderr, "[ERROR] Caught unknown return code, try verbose "
"option for more details\n");
hydra_child_exit(2);
}
run = next_run;
}
}
int32_t service_mcached_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be
// performed once only.
int32_t sock = -1;
int32_t myport = PORT_MCACHED;
char *buf;
if (port != 0)
myport = port;
sock = hydra_connect_tcp(ip, myport);
if (sock < 0) {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Can not connect\n");
return -1;
}
if (mcached_send_com_version(sock)) {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Can not send request\n");
return -1;
}
if (hydra_data_ready_timed(sock, 0, 1000) > 0) {
buf = hydra_receive_line(sock);
if (strstr(buf, "VERSION ")) {
hydra_report_found_host(port, ip, "memcached", fp);
mcached_send_com_quit(sock);
if (sock >= 0)
sock = hydra_disconnect(sock);
hydra_report(stderr, "[ERROR] Memcached server does not require any authentication\n");
}
free(buf);
return -1;
}
if (sock >= 0)
sock = hydra_disconnect(sock);
return 0;
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -4,11 +4,11 @@
#include "hydra.h" #include "hydra.h"
#ifdef __sun #ifdef __sun
#include <sys/int_types.h> #include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX) #elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
extern char quiet; extern char quiet;
@ -21,10 +21,10 @@ extern char *hydra_get_next_password();
extern void hydra_completed_pair(); extern void hydra_completed_pair();
extern void hydra_completed_pair_found(); extern void hydra_completed_pair_found();
extern void hydra_completed_pair_skip(); extern void hydra_completed_pair_skip();
extern void hydra_report_found(int32_t port, char *svc, FILE * fp); extern void hydra_report_found(int32_t port, char *svc, FILE *fp);
extern void hydra_report_pass_found(int32_t port, char *ip, char *svc, FILE * fp); extern void hydra_report_pass_found(int32_t port, char *ip, char *svc, FILE *fp);
extern void hydra_report_found_host(int32_t port, char *ip, char *svc, FILE * fp); extern void hydra_report_found_host(int32_t port, char *ip, char *svc, FILE *fp);
extern void hydra_report_found_host_msg(int32_t port, char *ip, char *svc, FILE * fp, char *msg); extern void hydra_report_found_host_msg(int32_t port, char *ip, char *svc, FILE *fp, char *msg);
extern void hydra_report_debug(FILE *st, char *format, ...); extern void hydra_report_debug(FILE *st, char *format, ...);
extern int32_t hydra_connect_to_ssl(int32_t socket, char *hostname); extern int32_t hydra_connect_to_ssl(int32_t socket, char *hostname);
extern int32_t hydra_connect_ssl(char *host, int32_t port, char *hostname); extern int32_t hydra_connect_ssl(char *host, int32_t port, char *hostname);
@ -67,7 +67,16 @@ char proxy_string_type[MAX_PROXY_COUNT][10];
char *proxy_authentication[MAX_PROXY_COUNT]; char *proxy_authentication[MAX_PROXY_COUNT];
char *cmdlinetarget; char *cmdlinetarget;
#ifndef __APPLE__
typedef int32_t BOOL; typedef int32_t BOOL;
#else /* __APPLE__ */
/* ensure compatibility with objc libraries */
#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
typedef bool BOOL;
#else
typedef signed char BOOL;
#endif
#endif /* __APPLE__ */
#define hydra_report fprintf #define hydra_report fprintf

195
hydra-mongodb.c Normal file
View file

@ -0,0 +1,195 @@
// This plugin was written by <david dot maciejak at gmail D O T com>
// Tested on mongodb-server 1:3.6.3-0ubuntu1
// MONGODB-CR is been deprecated
#ifdef LIBMONGODB
#include <mongoc.h>
#endif
#include "hydra-mod.h"
#ifndef LIBMONGODB
void dummy_mongodb() { printf("\n"); }
#else
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
char *buf;
#define DEFAULT_DB "admin"
int is_error_msg(char *msg) {
if (strstr(msg, "errmsg ")) {
if (debug)
hydra_report(stderr, "[ERROR] %s\n", msg);
return 1;
}
return 0;
}
int require_auth(int32_t sock) {
unsigned char m_hdr[] = "\x3f\x00\x00\x00" // messageLength (63)
"\x00\x00\x00\x41" // requestID
"\xff\xff\xff\xff" // responseTo
"\xd4\x07\x00\x00" // opCode (2004 OP_QUERY)
"\x00\x00\x00\x00" // flags
"\x61\x64\x6d\x69\x6e\x2e\x24\x63\x6d\x64\x00" // fullCollectionName
// (admin.$cmd)
"\x00\x00\x00\x00" // numberToSkip (0)
"\x01\x00\x00\x00" // numberToReturn (1)
"\x18\x00\x00\x00\x10\x6c\x69\x73\x74\x44\x61\x74\x61\x62\x61\x73\x65\x73"
"\x00\x01\x00\x00\x00\x00"; // query ({"listDatabases"=>1})
if (hydra_send(sock, m_hdr, sizeof(m_hdr), 0) > 0) {
if (hydra_data_ready_timed(sock, 0, 1000) > 0) {
buf = hydra_receive_line(sock);
return is_error_msg(buf);
}
}
return 2;
}
int32_t start_mongodb(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "";
char *login, *pass;
char uri[256];
mongoc_client_t *client;
mongoc_database_t *database;
mongoc_collection_t *collection;
mongoc_cursor_t *cursor;
bson_t q;
const bson_t *doc;
bson_error_t error;
bool r;
if (strlen(login = hydra_get_next_login()) == 0)
login = empty;
if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty;
mongoc_init();
mongoc_log_set_handler(NULL, NULL);
bson_init(&q);
if (login[0] == '\0' && pass[0] == '\0') {
snprintf(uri, sizeof(uri), "mongodb://%s:%d/?authSource=%s", hydra_address2string(ip), port, miscptr);
} else {
snprintf(uri, sizeof(uri), "mongodb://%s:%s@%s:%d/?authSource=%s", login, pass, hydra_address2string(ip), port, miscptr);
}
client = mongoc_client_new(uri);
if (!client) {
hydra_completed_pair_skip();
return 3;
}
mongoc_client_set_appname(client, "hydra");
collection = mongoc_client_get_collection(client, miscptr, "test");
cursor = mongoc_collection_find_with_opts(collection, &q, NULL, NULL);
r = mongoc_cursor_next(cursor, &doc);
if (!r) {
r = mongoc_cursor_error(cursor, &error);
if (r) {
if (verbose)
hydra_report(stderr, "[ERROR] Can not read document: %s\n", error.message);
mongoc_cursor_destroy(cursor);
mongoc_collection_destroy(collection);
mongoc_client_destroy(client);
mongoc_cleanup();
hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
return 3;
}
return 1;
}
}
mongoc_cursor_destroy(cursor);
mongoc_collection_destroy(collection);
mongoc_client_destroy(client);
mongoc_cleanup();
hydra_report_found_host(port, ip, "mongodb", fp);
hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3;
return 2;
}
void service_mongodb(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1;
if (!miscptr) {
if (verbose)
hydra_report(stderr, "[INFO] Using default database \"admin\"\n");
miscptr = DEFAULT_DB;
}
hydra_register_socket(sp);
while (1) {
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return;
switch (run) {
case 1:
next_run = start_mongodb(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
hydra_child_exit(0);
return;
default:
if (!verbose)
hydra_report(stderr, "[ERROR] Caught unknown return code, try verbose "
"option for more details\n");
hydra_child_exit(2);
}
run = next_run;
}
}
int32_t service_mongodb_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be
// performed once only.
int32_t myport = PORT_MONGODB;
int32_t sock = -1;
if (port != 0)
myport = port;
if ((options & OPTION_SSL) == 0)
sock = hydra_connect_tcp(ip, myport);
else
sock = hydra_connect_ssl(ip, myport, hostname);
if (sock < 0) {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Can not connect\n");
return -1;
}
if (!require_auth(sock)) {
hydra_report_found_host(port, ip, "mongodb", fp);
hydra_report(stderr, "[ERROR] Mongodb server does not require any authentication\n");
if (sock >= 0)
sock = hydra_disconnect(sock);
return -1;
}
if (sock >= 0)
sock = hydra_disconnect(sock);
return 0;
}
#endif
void usage_mongodb(const char *service) {
printf("Module mongodb is optionally taking a database name to attack, "
"default is \"admin\"\n\n");
}

View file

@ -1,53 +1,66 @@
#include "hydra-mod.h" #include "hydra-mod.h"
#define MSLEN 30
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
unsigned char p_hdr[] = #if defined(HAVE_SYBFRONT) && defined(HAVE_SYBDB)
"\x02\x00\x02\x00\x00\x00\x02\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00"; #include <sybdb.h>
unsigned char p_pk2[] = #include <sybfront.h>
"\x30\x30\x30\x30\x30\x30\x61\x30\x00\x00" #endif
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x20\x18\x81\xb8\x2c\x08\x03"
"\x01\x06\x0a\x09\x01\x01\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x73\x71\x75\x65\x6c\x64\x61"
"\x20\x31\x2e\x30\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00";
unsigned char p_pk3[] =
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x04\x02\x00\x00\x4d\x53\x44"
"\x42\x4c\x49\x42\x00\x00\x00\x07\x06\x00\x00" "\x00\x00\x0d\x11\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00";
unsigned char p_lng[] =
"\x02\x01\x00\x47\x00\x00\x02\x00\x00\x00\x00"
"\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x30\x30\x30\x00\x00" "\x00\x03\x00\x00\x00";
int32_t start_mssql(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { #define MSLEN 30
unsigned char p_hdr[] = "\x02\x00\x02\x00\x00\x00\x02\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00";
unsigned char p_pk2[] = "\x30\x30\x30\x30\x30\x30\x61\x30\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x20\x18\x81\xb8\x2c\x08\x03"
"\x01\x06\x0a\x09\x01\x01\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x73\x71\x75\x65\x6c\x64\x61"
"\x20\x31\x2e\x30\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00";
unsigned char p_pk3[] = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x04\x02\x00\x00\x4d\x53\x44"
"\x42\x4c\x49\x42\x00\x00\x00\x07\x06\x00\x00"
"\x00\x00\x0d\x11\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00";
unsigned char p_lng[] = "\x02\x01\x00\x47\x00\x00\x02\x00\x00\x00\x00"
"\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x30\x30\x30\x00\x00"
"\x00\x03\x00\x00\x00";
int32_t start_mssql(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[1024]; char *login, *pass, buffer[1024];
char *ipaddr_str = hydra_address2string(ip);
char ms_login[MSLEN + 1]; char ms_login[MSLEN + 1];
char ms_pass[MSLEN + 1]; char ms_pass[MSLEN + 1];
unsigned char len_login, len_pass; unsigned char len_login, len_pass;
@ -57,6 +70,42 @@ int32_t start_mssql(int32_t s, char *ip, int32_t port, unsigned char options, ch
login = empty; login = empty;
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty; pass = empty;
#if defined(HAVE_SYBFRONT) && defined(HAVE_SYBDB)
if ((strlen(login) > MSLEN) || (strlen(pass) > MSLEN)){
DBPROCESS *dbproc;
LOGINREC *attempt;
attempt = dblogin();
DBSETLUSER(attempt, login);
DBSETLPWD(attempt, pass);
// Connect without specifying a database
dbproc = dbopen(attempt, ipaddr_str);
if (dbproc != NULL) {
dbclose(dbproc);
dbexit();
hydra_report_found_host(port, ip, "mssql", fp);
hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 2;
return 1;
}
hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 2;
return 1;
}
#else
if ((strlen(login) > MSLEN) || (strlen(pass) > MSLEN)){
fprintf(stderr,"[WARNING] To crack credentials longer than 30 characters, install freetds and recompile\n");
}
#endif
if (strlen(login) > MSLEN) if (strlen(login) > MSLEN)
login[MSLEN - 1] = 0; login[MSLEN - 1] = 0;
if (strlen(pass) > MSLEN) if (strlen(pass) > MSLEN)
@ -81,7 +130,7 @@ int32_t start_mssql(int32_t s, char *ip, int32_t port, unsigned char options, ch
if (hydra_send(s, buffer, MSLEN + 1 + 39 + MSLEN + 1 + 110 + 1 + MSLEN + 270, 0) < 0) if (hydra_send(s, buffer, MSLEN + 1 + 39 + MSLEN + 1 + 110 + 1 + MSLEN + 270, 0) < 0)
return 1; return 1;
if (hydra_send(s, (char *) p_lng, 71, 0) < 0) if (hydra_send(s, (char *)p_lng, 71, 0) < 0)
return 1; return 1;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
@ -107,16 +156,20 @@ int32_t start_mssql(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_mssql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_mssql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_MSSQL, mysslport = PORT_MSSQL_SSL; int32_t myport = PORT_MSSQL, mysslport = PORT_MSSQL_SSL;
#if defined(HAVE_SYBFRONT) && defined(HAVE_SYBDB)
dbinit();
#endif
hydra_register_socket(sp); hydra_register_socket(sp);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -129,18 +182,18 @@ void service_mssql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = start_mssql(sock, ip, port, options, miscptr, fp); next_run = start_mssql(sock, ip, port, options, miscptr, fp);
hydra_disconnect(sock); hydra_disconnect(sock);
break; break;
case 2: /* clean exit */ case 2: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -153,13 +206,13 @@ void service_mssql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
} }
} }
int32_t service_mssql_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_mssql_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -1,19 +1,16 @@
/* mysql 3.2x.x to 4.x support - by mcbethh (at) u-n-f (dot) com */ /* mysql 3.2x.x to 4.x support - by mcbethh (at) u-n-f (dot) com */
/* david (dot) maciejak (at) gmail (dot) com for using libmysqlclient-dev, adding support for mysql version 5.x */ /* david (dot) maciejak (at) gmail (dot) com for using libmysqlclient-dev,
* adding support for mysql version 5.x */
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef HAVE_MATH_H #ifndef HAVE_MATH_H
#include <stdio.h> #include <stdio.h>
void dummy_mysql() { void dummy_mysql() { printf("\n"); }
printf("\n");
}
void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { printf("\n"); }
printf("\n");
}
#else #else
#include <math.h> #include <math.h>
@ -38,10 +35,12 @@ char *hydra_scramble(char *to, const char *message, const char *password);
extern int32_t internal__hydra_recv(int32_t socket, char *buf, int32_t length); extern int32_t internal__hydra_recv(int32_t socket, char *buf, int32_t length);
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec); extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char mysqlsalt[9]; char mysqlsalt[9];
/* modified hydra_receive_line, I've striped code which changed every 0x00 to 0x20 */ /* modified hydra_receive_line, I've striped code which changed every 0x00 to
* 0x20 */
char *hydra_mysql_receive_line(int32_t socket) { char *hydra_mysql_receive_line(int32_t socket) {
char buf[300], *buff, *buff2; char buf[300], *buff, *buff2;
int32_t i = 0, j = 0, buff_size = 300; int32_t i = 0, j = 0, buff_size = 300;
@ -51,7 +50,7 @@ char *hydra_mysql_receive_line(int32_t socket) {
return NULL; return NULL;
memset(buff, 0, sizeof(buf)); memset(buff, 0, sizeof(buf));
i = hydra_data_ready_timed(socket, (long) waittime, 0); i = hydra_data_ready_timed(socket, (long)waittime, 0);
if (i > 0) { if (i > 0) {
if ((i = internal__hydra_recv(socket, buff, sizeof(buf))) < 0) { if ((i = internal__hydra_recv(socket, buff, sizeof(buf))) < 0) {
free(buff); free(buff);
@ -98,7 +97,7 @@ char hydra_mysql_init(int32_t sock) {
protocol = buf[4]; protocol = buf[4];
if (protocol == 0xff) { if (protocol == 0xff) {
pos = &buf[6]; pos = &buf[6];
// *(strchr(pos, '.')) = '\0'; // *(strchr(pos, '.')) = '\0';
hydra_report(stderr, "[ERROR] %s\n", pos); hydra_report(stderr, "[ERROR] %s\n", pos);
free(buf); free(buf);
return 2; return 2;
@ -108,7 +107,10 @@ char hydra_mysql_init(int32_t sock) {
return 2; return 2;
} }
if (protocol > 10) { if (protocol > 10) {
fprintf(stderr, "[INFO] This is protocol version %d, only v10 is supported, not sure if it will work\n", protocol); fprintf(stderr,
"[INFO] This is protocol version %d, only v10 is supported, not "
"sure if it will work\n",
protocol);
} }
server_version = &buf[5]; server_version = &buf[5];
pos = buf + strlen(server_version) + 10; pos = buf + strlen(server_version) + 10;
@ -116,7 +118,8 @@ char hydra_mysql_init(int32_t sock) {
if (!strstr(server_version, "3.") && !strstr(server_version, "4.") && strstr(server_version, "5.")) { if (!strstr(server_version, "3.") && !strstr(server_version, "4.") && strstr(server_version, "5.")) {
#ifndef LIBMYSQLCLIENT #ifndef LIBMYSQLCLIENT
hydra_report(stderr, "[ERROR] Not an MySQL protocol or unsupported version,\ncheck configure to see if libmysql is found\n"); hydra_report(stderr, "[ERROR] Not an MySQL protocol or unsupported version,\ncheck "
"configure to see if libmysql is found\n");
#endif #endif
free(buf); free(buf);
return 2; return 2;
@ -130,35 +133,32 @@ char hydra_mysql_init(int32_t sock) {
char *hydra_mysql_prepare_auth(char *login, char *pass) { char *hydra_mysql_prepare_auth(char *login, char *pass) {
unsigned char *response; unsigned char *response;
unsigned long login_len = strlen(login) > 32 ? 32 : strlen(login); unsigned long login_len = strlen(login) > 32 ? 32 : strlen(login);
unsigned long response_len = 4 /* header */ + unsigned long response_len = 4 /* header */ + 2 /* client flags */ + 3 /* max packet len */ + login_len + 1 + 8 /* scrambled password len */;
2 /* client flags */ +
3 /* max packet len */ +
login_len + 1 + 8 /* scrambled password len */ ;
response = (unsigned char *) malloc(response_len + 4); response = (unsigned char *)malloc(response_len + 4);
if (response == NULL) { if (response == NULL) {
fprintf(stderr, "[ERROR] could not allocate memory\n"); fprintf(stderr, "[ERROR] could not allocate memory\n");
return NULL; return NULL;
} }
memset(response, 0, response_len + 4); memset(response, 0, response_len + 4);
*((unsigned long *) response) = response_len - 4; *((unsigned long *)response) = response_len - 4;
response[3] = 0x01; /* packet number */ response[3] = 0x01; /* packet number */
response[4] = 0x85; response[4] = 0x85;
response[5] = 0x24; /* client flags */ response[5] = 0x24; /* client flags */
response[6] = response[7] = response[8] = 0x00; /* max packet */ response[6] = response[7] = response[8] = 0x00; /* max packet */
memcpy(&response[9], login, login_len); /* login */ memcpy(&response[9], login, login_len); /* login */
response[9 + login_len] = '\0'; /* null terminate login */ response[9 + login_len] = '\0'; /* null terminate login */
hydra_scramble((char *) &response[9 + login_len + 1], mysqlsalt, pass); hydra_scramble((char *)&response[9 + login_len + 1], mysqlsalt, pass);
return (char *) response; return (char *)response;
} }
/* returns 0 if authentication succeed */ /* returns 0 if authentication succeed */
/* and 1 if failed */ /* and 1 if failed */
char hydra_mysql_parse_response(unsigned char *response) { char hydra_mysql_parse_response(unsigned char *response) {
unsigned long response_len = *((unsigned long *) response) & 0xffffff; unsigned long response_len = *((unsigned long *)response) & 0xffffff;
if (response_len < 4) if (response_len < 4)
return 0; return 0;
@ -170,29 +170,23 @@ char hydra_mysql_parse_response(unsigned char *response) {
} }
char hydra_mysql_send_com_quit(int32_t sock) { char hydra_mysql_send_com_quit(int32_t sock) {
char com_quit_packet[5] = { 0x01, 0x00, 0x00, 0x00, 0x01 }; char com_quit_packet[5] = {0x01, 0x00, 0x00, 0x00, 0x01};
hydra_send(sock, com_quit_packet, 5, 0); hydra_send(sock, com_quit_packet, 5, 0);
return 0; return 0;
} }
int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *response = NULL, *login = NULL, *pass = NULL; char *response = NULL, *login = NULL, *pass = NULL;
unsigned long response_len; unsigned long response_len;
char res = 0; char res = 0;
char database[256]; char *database = NULL;
login = hydra_get_next_login(); login = hydra_get_next_login();
pass = hydra_get_next_password(); pass = hydra_get_next_password();
if (miscptr) if (miscptr)
strncpy(database, miscptr, sizeof(database) - 1); database = miscptr;
else {
strncpy(database, DEFAULT_DB, sizeof(database) - 1);
if (verbose)
hydra_report(stderr, "[VERBOSE] using default db 'mysql'\n");
}
database[sizeof(database) - 1] = 0;
/* read server greeting */ /* read server greeting */
res = hydra_mysql_init(sock); res = hydra_mysql_init(sock);
@ -227,7 +221,8 @@ int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options,
} }
if (my_errno == 1251) { if (my_errno == 1251) {
hydra_report(stderr, "[ERROR] Client does not support authentication protocol requested by server\n"); hydra_report(stderr, "[ERROR] Client does not support authentication "
"protocol requested by server\n");
} }
/* /*
@ -241,8 +236,8 @@ int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options,
*/ */
//if the error is more critical, we just try to reconnect // if the error is more critical, we just try to reconnect
//to the db later with the mysql_init // to the db later with the mysql_init
if ((my_errno != 1044) && (my_errno != 1045)) { if ((my_errno != 1044) && (my_errno != 1045)) {
mysql_close(mysql); mysql_close(mysql);
mysql = NULL; mysql = NULL;
@ -270,7 +265,7 @@ int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options,
response = hydra_mysql_prepare_auth(login, pass); response = hydra_mysql_prepare_auth(login, pass);
if (response == NULL) if (response == NULL)
return 3; return 3;
response_len = *((unsigned long *) response) & 0xffffff; response_len = *((unsigned long *)response) & 0xffffff;
/* send client auth packet */ /* send client auth packet */
/* dunny why, mysql IO code had problem reading my response. */ /* dunny why, mysql IO code had problem reading my response. */
@ -286,7 +281,7 @@ int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options,
/* read authentication response */ /* read authentication response */
if ((response = hydra_mysql_receive_line(sock)) == NULL) if ((response = hydra_mysql_receive_line(sock)) == NULL)
return 1; return 1;
res = hydra_mysql_parse_response((unsigned char *) response); res = hydra_mysql_parse_response((unsigned char *)response);
if (!res) { if (!res) {
hydra_mysql_send_com_quit(sock); hydra_mysql_send_com_quit(sock);
@ -308,7 +303,7 @@ int32_t start_mysql(int32_t sock, char *ip, int32_t port, unsigned char options,
return 1; return 1;
} }
void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_MYSQL; int32_t myport = PORT_MYSQL;
@ -317,12 +312,12 @@ void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) { if (sock >= 0) {
hydra_mysql_send_com_quit(sock); hydra_mysql_send_com_quit(sock);
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
} }
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -330,15 +325,18 @@ void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
port = myport; port = myport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_mysql(sock, ip, port, options, miscptr, fp); next_run = start_mysql(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) { if (sock >= 0) {
hydra_mysql_send_com_quit(sock); hydra_mysql_send_com_quit(sock);
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
@ -355,8 +353,6 @@ void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
#ifndef LIBMYSQLCLIENT #ifndef LIBMYSQLCLIENT
#endif #endif
/************************************************************************/ /************************************************************************/
@ -373,9 +369,9 @@ struct hydra_rand_struct {
double max_value_dbl; double max_value_dbl;
}; };
void hydra_randominit(struct hydra_rand_struct *rand_st, unsigned long seed1, unsigned long seed2) { /* For mysql 3.21.# */ void hydra_randominit(struct hydra_rand_struct *rand_st, unsigned long seed1, unsigned long seed2) { /* For mysql 3.21.# */
rand_st->max_value = 0x3FFFFFFFL; rand_st->max_value = 0x3FFFFFFFL;
rand_st->max_value_dbl = (double) rand_st->max_value; rand_st->max_value_dbl = (double)rand_st->max_value;
rand_st->seed1 = seed1 % rand_st->max_value; rand_st->seed1 = seed1 % rand_st->max_value;
rand_st->seed2 = seed2 % rand_st->max_value; rand_st->seed2 = seed2 % rand_st->max_value;
} }
@ -383,7 +379,7 @@ void hydra_randominit(struct hydra_rand_struct *rand_st, unsigned long seed1, un
double hydra_rnd(struct hydra_rand_struct *rand_st) { double hydra_rnd(struct hydra_rand_struct *rand_st) {
rand_st->seed1 = (rand_st->seed1 * 3 + rand_st->seed2) % rand_st->max_value; rand_st->seed1 = (rand_st->seed1 * 3 + rand_st->seed2) % rand_st->max_value;
rand_st->seed2 = (rand_st->seed1 + rand_st->seed2 + 33) % rand_st->max_value; rand_st->seed2 = (rand_st->seed1 + rand_st->seed2 + 33) % rand_st->max_value;
return (((double) rand_st->seed1) / rand_st->max_value_dbl); return (((double)rand_st->seed1) / rand_st->max_value_dbl);
} }
void hydra_hash_password(unsigned long *result, const char *password) { void hydra_hash_password(unsigned long *result, const char *password) {
register unsigned long nr = 1345345333L, add = 7, nr2 = 0x12345671L; register unsigned long nr = 1345345333L, add = 7, nr2 = 0x12345671L;
@ -391,14 +387,15 @@ void hydra_hash_password(unsigned long *result, const char *password) {
for (; *password; password++) { for (; *password; password++) {
if (*password == ' ' || *password == '\t') if (*password == ' ' || *password == '\t')
continue; /* skipp space in password */ continue; /* skipp space in password */
tmp = (unsigned long) (unsigned char) *password; tmp = (unsigned long)(unsigned char)*password;
nr ^= (((nr & 63) + add) * tmp) + (nr << 8); nr ^= (((nr & 63) + add) * tmp) + (nr << 8);
nr2 += (nr2 << 8) ^ nr; nr2 += (nr2 << 8) ^ nr;
add += tmp; add += tmp;
} }
result[0] = nr & (((unsigned long) 1L << 31) - 1L); /* Don't use sign bit (str2int) */ ; result[0] = nr & (((unsigned long)1L << 31) - 1L); /* Don't use sign bit (str2int) */
result[1] = nr2 & (((unsigned long) 1L << 31) - 1L); ;
result[1] = nr2 & (((unsigned long)1L << 31) - 1L);
return; return;
} }
@ -414,8 +411,8 @@ char *hydra_scramble(char *to, const char *message, const char *password) {
hydra_hash_password(hash_message, message); hydra_hash_password(hash_message, message);
hydra_randominit(&rand_st, hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]); hydra_randominit(&rand_st, hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]);
while (*message++) while (*message++)
*to++ = (char) (floor(hydra_rnd(&rand_st) * 31) + 64); *to++ = (char)(floor(hydra_rnd(&rand_st) * 31) + 64);
extra = (char) (floor(hydra_rnd(&rand_st) * 31)); extra = (char)(floor(hydra_rnd(&rand_st) * 31));
while (to_start != to) while (to_start != to)
*(to_start++) ^= extra; *(to_start++) ^= extra;
} }
@ -424,13 +421,13 @@ char *hydra_scramble(char *to, const char *message, const char *password) {
} }
#endif #endif
int32_t service_mysql_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_mysql_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -438,6 +435,7 @@ int32_t service_mysql_init(char *ip, int32_t sp, unsigned char options, char *mi
return 0; return 0;
} }
void usage_mysql(const char* service) { void usage_mysql(const char *service) {
printf("Module mysql is optionally taking the database to attack, default is \"mysql\"\n\n"); printf("Module mysql is optionally taking the database to attack, default is "
"\"mysql\"\n\n");
} }

View file

@ -1,28 +1,25 @@
/* /*
* Novell Network Core Protocol Support - by David Maciejak @ GMAIL dot com * Novell Network Core Protocol Support - by David Maciejak @ GMAIL dot com
* Tested on Netware 6.5 * Tested on Netware 6.5
* *
* you need to install libncp and libncp-dev (tested with version 2.2.6-3) * you need to install libncp and libncp-dev (tested with version 2.2.6-3)
* *
* you can passed full context as OPT * you can passed full context as OPT
* *
* example: ./hydra -L login -P passw 172.16.246.129 ncp .O=cx * example: ./hydra -L login -P passw 172.16.246.129 ncp .O=cx
* *
*/ */
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBNCP #ifndef LIBNCP
void dummy_ncp() { void dummy_ncp() { printf("\n"); }
printf("\n");
}
#else #else
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ncp/nwcalls.h> #include <ncp/nwcalls.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
extern int32_t child_head_no; extern int32_t child_head_no;
@ -33,11 +30,10 @@ typedef struct __NCP_DATA {
char *context; char *context;
} _NCP_DATA; } _NCP_DATA;
//uncomment line below to see more trace stack // uncomment line below to see more trace stack
//#define NCP_DEBUG //#define NCP_DEBUG
int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *login; char *login;
char *pass; char *pass;
char context[256]; char context[256];
@ -47,13 +43,11 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
_NCP_DATA *session; _NCP_DATA *session;
session = malloc(sizeof(_NCP_DATA)); session = malloc(sizeof(_NCP_DATA));
memset(session, 0, sizeof(_NCP_DATA)); memset(session, 0, sizeof(_NCP_DATA));
login = empty; login = empty;
pass = empty; pass = empty;
if (strlen(login = hydra_get_next_login()) == 0) { if (strlen(login = hydra_get_next_login()) == 0) {
login = empty; login = empty;
} else { } else {
@ -71,8 +65,8 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
} }
} }
//login and password are case insensitive // login and password are case insensitive
//str_upper(login); // str_upper(login);
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty; pass = empty;
@ -91,27 +85,27 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
memset(session->spec.password, 0, sizeof(session->spec.password)); memset(session->spec.password, 0, sizeof(session->spec.password));
memcpy(session->spec.password, pass, strlen(pass) + 1); memcpy(session->spec.password, pass, strlen(pass) + 1);
//str_upper(session->spec.password); // str_upper(session->spec.password);
ncp_lib_error_code = ncp_login_conn(session->conn, session->spec.user, object_type, session->spec.password); ncp_lib_error_code = ncp_login_conn(session->conn, session->spec.user, object_type, session->spec.password);
switch (ncp_lib_error_code & 0x0000FFFF) { switch (ncp_lib_error_code & 0x0000FFFF) {
case 0x0000: /* Success */ case 0x0000: /* Success */
#ifdef NCP_DEBUG #ifdef NCP_DEBUG
printf("Connection success (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code); printf("Connection success (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code);
#endif #endif
ncp_close(session->conn); ncp_close(session->conn);
hydra_report_found_host(port, ip, "ncp", fp); //ok hydra_report_found_host(port, ip, "ncp", fp); // ok
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; //exit return 3; // exit
free(session); free(session);
return 2; //next return 2; // next
break; break;
case 0x89DE: /* PASSWORD INVALID */ case 0x89DE: /* PASSWORD INVALID */
case 0x89F0: /* BIND WILDCARD INVALID */ case 0x89F0: /* BIND WILDCARD INVALID */
case 0x89FF: /* NO OBJ OR BAD PASSWORD */ case 0x89FF: /* NO OBJ OR BAD PASSWORD */
case 0xFD63: /* FAILED_AUTHENTICATION */ case 0xFD63: /* FAILED_AUTHENTICATION */
case 0xFDA7: /* NO_SUCH_ENTRY */ case 0xFDA7: /* NO_SUCH_ENTRY */
#ifdef NCP_DEBUG #ifdef NCP_DEBUG
printf("Incorrect password (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code); printf("Incorrect password (%s / %s). Error code: %X\n", login, pass, ncp_lib_error_code);
#endif #endif
@ -119,7 +113,7 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
hydra_completed_pair(); hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) { if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
free(session); free(session);
return 2; //next return 2; // next
} }
break; break;
default: default:
@ -131,10 +125,10 @@ int32_t start_ncp(int32_t s, char *ip, int32_t port, unsigned char options, char
break; break;
} }
free(session); free(session);
return 1; //reconnect return 1; // reconnect
} }
void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_NCP; int32_t myport = PORT_NCP;
@ -144,7 +138,7 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if (port != 0) if (port != 0)
@ -152,14 +146,15 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: case 2:
/* /*
* Here we start the password cracking process * Here we start the password cracking process
*/ */
next_run = start_ncp(sock, ip, port, options, miscptr, fp); next_run = start_ncp(sock, ip, port, options, miscptr, fp);
break; break;
@ -183,13 +178,13 @@ void service_ncp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
#endif #endif
int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -197,6 +192,7 @@ int32_t service_ncp_init(char *ip, int32_t sp, unsigned char options, char *misc
return 0; return 0;
} }
void usage_ncp(const char* service) { void usage_ncp(const char *service) {
printf("Module ncp is optionally taking the full context, for example \".O=cx\"\n\n"); printf("Module ncp is optionally taking the full context, for example "
"\".O=cx\"\n\n");
} }

View file

@ -25,7 +25,7 @@ char *nntp_read_server_capacity(int32_t sock) {
free(buf); free(buf);
ptr = buf = hydra_receive_line(sock); ptr = buf = hydra_receive_line(sock);
if (buf != NULL) { if (buf != NULL) {
if (isdigit((int32_t) buf[0]) && buf[3] == ' ') if (isdigit((int32_t)buf[0]) && buf[3] == ' ')
resp = 1; resp = 1;
else { else {
if (buf[strlen(buf) - 1] == '\n') if (buf[strlen(buf) - 1] == '\n')
@ -38,7 +38,7 @@ char *nntp_read_server_capacity(int32_t sock) {
if ((ptr = strrchr(buf, '\n')) != NULL) { if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif #endif
ptr++; ptr++;
if (isdigit((int32_t) *ptr) && *(ptr + 3) == ' ') if (isdigit((int32_t)*ptr) && *(ptr + 3) == ' ')
resp = 1; resp = 1;
} }
} }
@ -47,8 +47,8 @@ char *nntp_read_server_capacity(int32_t sock) {
return buf; return buf;
} }
int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\""; char *empty = "\"\"", *result = NULL;
char *login, *pass, buffer[500], buffer2[500], *fooptr; char *login, *pass, buffer[500], buffer2[500], *fooptr;
int32_t i = 1; int32_t i = 1;
@ -79,7 +79,7 @@ int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
free(buf); free(buf);
strcpy(buffer2, login); strcpy(buffer2, login);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -94,7 +94,7 @@ int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
free(buf); free(buf);
strcpy(buffer2, pass); strcpy(buffer2, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
break; break;
case AUTH_PLAIN: case AUTH_PLAIN:
@ -112,7 +112,9 @@ int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, cha
free(buf); free(buf);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
sasl_plain(buffer, login, pass); result = sasl_plain(buffer, login, pass);
if (result == NULL)
return 3;
char tmp_buffer[sizeof(buffer)]; char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer); sprintf(tmp_buffer, "%.250s\r\n", buffer);
@ -120,128 +122,125 @@ int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, cha
break; break;
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_CRAMMD5:{ case AUTH_CRAMMD5: {
int32_t rc = 0; int32_t rc = 0;
char *preplogin; char *preplogin;
rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin); rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) { if (rc) {
return 3; return 3;
}
sprintf(buffer, "AUTHINFO SASL CRAM-MD5\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
//get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (buf == NULL || strstr(buf, "383") == NULL) {
hydra_report(stderr, "[ERROR] NNTP CRAM-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 4);
free(buf);
memset(buffer2, 0, sizeof(buffer2));
sasl_cram_md5(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
hydra_tobase64((unsigned char *) buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} }
break;
case AUTH_DIGESTMD5:{ sprintf(buffer, "AUTHINFO SASL CRAM-MD5\r\n");
sprintf(buffer, "AUTHINFO SASL DIGEST-MD5\r\n"); if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
//receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (buf == NULL || strstr(buf, "383") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] NNTP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 4);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "nntp", NULL, 0, NULL);
if (fooptr == NULL)
return 3;
if (debug)
hydra_report(stderr, "DEBUG C: %s\n", buffer2);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} }
break; // get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (buf == NULL || strstr(buf, "383") == NULL) {
hydra_report(stderr, "[ERROR] NNTP CRAM-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf + 4);
free(buf);
memset(buffer2, 0, sizeof(buffer2));
result = sasl_cram_md5(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
hydra_tobase64((unsigned char *)buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} break;
case AUTH_DIGESTMD5: {
sprintf(buffer, "AUTHINFO SASL DIGEST-MD5\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
// receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (buf == NULL || strstr(buf, "383") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] NNTP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf + 4);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2;
result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "nntp", NULL, 0, NULL);
if (result == NULL)
return 3;
if (debug)
hydra_report(stderr, "DEBUG C: %s\n", buffer2);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} break;
#endif #endif
case AUTH_NTLM:{ case AUTH_NTLM: {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
//send auth and receive challenge // send auth and receive challenge
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL); buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2)); to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
sprintf(buffer, "AUTHINFO SASL NTLM %s\r\n", (char *) buf1); sprintf(buffer, "AUTHINFO SASL NTLM %s\r\n", (char *)buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1; return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (buf == NULL || strstr(buf, "383") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] NNTP NTLM AUTH : %s\n", buf);
free(buf);
return 3;
}
//recover challenge
from64tobits((char *) buf1, buf + 4);
free(buf);
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2));
sprintf(buffer, "%s\r\n", (char *) buf1);
} }
break; if ((buf = hydra_receive_line(s)) == NULL)
return 1;
default:{ if (buf == NULL || strstr(buf, "383") == NULL || strlen(buf) < 8) {
sprintf(buffer, "AUTHINFO USER %.250s\r\n", login); hydra_report(stderr, "[ERROR] NNTP NTLM AUTH : %s\n", buf);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
buf = hydra_receive_line(s);
if (buf == NULL)
return 1;
if (buf[0] != '3') {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an NNTP protocol or service shutdown: %s\n", buf);
free(buf);
return (3);
}
free(buf); free(buf);
sprintf(buffer, "AUTHINFO PASS %.250s\r\n", pass); return 3;
} }
break; // recover challenge
from64tobits((char *)buf1, buf + 4);
free(buf);
buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "%s\r\n", (char *)buf1);
} break;
default: {
sprintf(buffer, "AUTHINFO USER %.250s\r\n", login);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
buf = hydra_receive_line(s);
if (buf == NULL)
return 1;
if (buf[0] != '3') {
if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an NNTP protocol or service shutdown: %s\n", buf);
free(buf);
return (3);
}
free(buf);
sprintf(buffer, "AUTHINFO PASS %.250s\r\n", pass);
} break;
} }
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1; return 1;
} }
@ -266,7 +265,7 @@ int32_t start_nntp(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 2; return 2;
} }
void service_nntp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_nntp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t i = 0, run = 1, next_run = 1, sock = -1; int32_t i = 0, run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_NNTP, mysslport = PORT_NNTP_SSL, disable_tls = 0; int32_t myport = PORT_NNTP, mysslport = PORT_NNTP_SSL, disable_tls = 0;
char *buffer1 = "CAPABILITIES\r\n"; char *buffer1 = "CAPABILITIES\r\n";
@ -276,10 +275,10 @@ void service_nntp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -293,12 +292,12 @@ void service_nntp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
// usleepn(300); // usleepn(300);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '2') { /* check the first line */ if (buf == NULL || buf[0] != '2') { /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an NNTP protocol or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] Not an NNTP protocol or service shutdown: %s\n", buf);
hydra_child_exit(2); hydra_child_exit(2);
@ -352,10 +351,10 @@ void service_nntp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
#endif #endif
/* /*
AUTHINFO USER SASL AUTHINFO USER SASL
SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5 SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
*/ */
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if (hydra_string_match(buf, "SASL\\s.*NTLM")) { if (hydra_string_match(buf, "SASL\\s.*NTLM")) {
@ -405,7 +404,7 @@ SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
for (i = 0; i < strlen(miscptr); i++) for (i = 0; i < strlen(miscptr); i++)
miscptr[i] = (char) toupper((int32_t) miscptr[i]); miscptr[i] = (char)toupper((int32_t)miscptr[i]);
if (strncmp(miscptr, "USER", 4) == 0) if (strncmp(miscptr, "USER", 4) == 0)
nntp_auth_mechanism = AUTH_CLEAR; nntp_auth_mechanism = AUTH_CLEAR;
@ -426,7 +425,6 @@ SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
if (strncmp(miscptr, "NTLM", 4) == 0) if (strncmp(miscptr, "NTLM", 4) == 0)
nntp_auth_mechanism = AUTH_NTLM; nntp_auth_mechanism = AUTH_NTLM;
} }
if (verbose) { if (verbose) {
switch (nntp_auth_mechanism) { switch (nntp_auth_mechanism) {
@ -456,10 +454,10 @@ SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
free(buf); free(buf);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_nntp(sock, ip, port, options, miscptr, fp); next_run = start_nntp(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -472,13 +470,13 @@ SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
} }
} }
int32_t service_nntp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_nntp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -486,6 +484,7 @@ int32_t service_nntp_init(char *ip, int32_t sp, unsigned char options, char *mis
return 0; return 0;
} }
void usage_nntp(const char* service) { void usage_nntp(const char *service) {
printf("Module nntp is optionally taking one authentication type of:\n" " USER (default), LOGIN, PLAIN, CRAM-MD5, DIGEST-MD5, NTLM\n\n"); printf("Module nntp is optionally taking one authentication type of:\n"
" USER (default), LOGIN, PLAIN, CRAM-MD5, DIGEST-MD5, NTLM\n\n");
} }

View file

@ -13,14 +13,13 @@ at http://marcellmajor.com/frame_listenerhash.html
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBOPENSSL #ifndef LIBOPENSSL
#include <stdio.h> #include <stdio.h>
void dummy_oracle_listener() { void dummy_oracle_listener() { printf("\n"); }
printf("\n");
}
#else #else
#include "sasl.h" #include "sasl.h"
#include <openssl/des.h> #include <openssl/des.h>
#define HASHSIZE 17 #define HASHSIZE 17
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
unsigned char *hash; unsigned char *hash;
@ -31,7 +30,7 @@ int32_t initial_permutation(unsigned char **result, char *p_str, int32_t *sz) {
int32_t i = strlen(p_str); int32_t i = strlen(p_str);
char *buff; char *buff;
//expand the string with zero so that length is a multiple of 4 // expand the string with zero so that length is a multiple of 4
while ((i % 4) != 0) { while ((i % 4) != 0) {
i = i + 1; i = i + 1;
} }
@ -44,14 +43,14 @@ int32_t initial_permutation(unsigned char **result, char *p_str, int32_t *sz) {
memset(buff, 0, i + 4); memset(buff, 0, i + 4);
strcpy(buff, p_str); strcpy(buff, p_str);
//swap the order of every byte pair // swap the order of every byte pair
for (k = 0; k < i; k += 2) { for (k = 0; k < i; k += 2) {
char bck = buff[k + 1]; char bck = buff[k + 1];
buff[k + 1] = buff[k]; buff[k + 1] = buff[k];
buff[k] = bck; buff[k] = bck;
} }
//convert to unicode // convert to unicode
if ((*result = malloc(2 * i)) == NULL) { if ((*result = malloc(2 * i)) == NULL) {
hydra_report(stderr, "[ERROR] Can't allocate memory\n"); hydra_report(stderr, "[ERROR] Can't allocate memory\n");
free(buff); free(buff);
@ -75,7 +74,7 @@ int32_t ora_hash(unsigned char **orahash, unsigned char *buf, int32_t len) {
} }
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
sprintf(((char *) *orahash) + i * 2, "%02X", buf[len - 8 + i]); sprintf(((char *)*orahash) + i * 2, "%02X", buf[len - 8 + i]);
} }
return 0; return 0;
} }
@ -106,8 +105,8 @@ int32_t ora_descrypt(unsigned char **rs, unsigned char *result, int32_t siz) {
int32_t i = 0; int32_t i = 0;
char lastkey[8]; char lastkey[8];
DES_key_schedule ks1; DES_key_schedule ks1;
unsigned char key1[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }; unsigned char key1[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
unsigned char ivec1[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned char ivec1[] = {0, 0, 0, 0, 0, 0, 0, 0};
unsigned char *desresult; unsigned char *desresult;
memset(ivec1, 0, sizeof(ivec1)); memset(ivec1, 0, sizeof(ivec1));
@ -115,14 +114,14 @@ int32_t ora_descrypt(unsigned char **rs, unsigned char *result, int32_t siz) {
hydra_report(stderr, "[ERROR] Can't allocate memory\n"); hydra_report(stderr, "[ERROR] Can't allocate memory\n");
return 1; return 1;
} }
DES_key_sched((const_DES_cblock *) key1, &ks1); DES_key_sched((const_DES_cblock *)key1, &ks1);
DES_ncbc_encrypt(result, desresult, siz, &ks1, &ivec1, DES_ENCRYPT); DES_ncbc_encrypt(result, desresult, siz, &ks1, &ivec1, DES_ENCRYPT);
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
lastkey[i] = desresult[siz - 8 + i]; lastkey[i] = desresult[siz - 8 + i];
} }
DES_key_sched((const_DES_cblock *) lastkey, &ks1); DES_key_sched((const_DES_cblock *)lastkey, &ks1);
memset(desresult, 0, siz); memset(desresult, 0, siz);
memset(ivec1, 0, sizeof(ivec1)); memset(ivec1, 0, sizeof(ivec1));
DES_ncbc_encrypt(result, desresult, siz, &ks1, &ivec1, DES_ENCRYPT); DES_ncbc_encrypt(result, desresult, siz, &ks1, &ivec1, DES_ENCRYPT);
@ -146,7 +145,7 @@ int32_t ora_hash_password(char *pass) {
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
//concatenate Arb string and convert the resulting string to uppercase // concatenate Arb string and convert the resulting string to uppercase
snprintf(buff, sizeof(buff), "Arb%s", pass); snprintf(buff, sizeof(buff), "Arb%s", pass);
strupper(buff); strupper(buff);
@ -179,13 +178,11 @@ int32_t ora_hash_password(char *pass) {
return 0; return 0;
} }
int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
unsigned char tns_packet_begin[22] = { unsigned char tns_packet_begin[22] = {"\x00\x00\x01\x00\x00\x00\x01\x36\x01\x2c\x00\x00\x08\x00\x7f\xff\x86\x0e"
"\x00\x00\x01\x00\x00\x00\x01\x36\x01\x2c\x00\x00\x08\x00\x7f\xff\x86\x0e\x00\x00\x01\x00" "\x00\x00\x01\x00"};
}; unsigned char tns_packet_end[32] = {"\x00\x3a\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
unsigned char tns_packet_end[32] = { "\x00\x00\x09\x94\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00"};
"\x00\x3a\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x09\x94\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00"
};
char *empty = ""; char *empty = "";
char *pass; char *pass;
@ -210,9 +207,12 @@ int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char o
free(hash); free(hash);
return 1; return 1;
} }
pass = (char *) hash; pass = (char *)hash;
} }
snprintf(connect_string, sizeof(connect_string), "(DESCRIPTION=(CONNECT_DATA=(CID=(PROGRAM=))(COMMAND=reload)(PASSWORD=%s)(SERVICE=)(VERSION=169869568)))", pass); snprintf(connect_string, sizeof(connect_string),
"(DESCRIPTION=(CONNECT_DATA=(CID=(PROGRAM=))(COMMAND=reload)("
"PASSWORD=%s)(SERVICE=)(VERSION=169869568)))",
pass);
if (hash != NULL) if (hash != NULL)
free(hash); free(hash);
@ -226,7 +226,7 @@ int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char o
} else { } else {
buffer2[1] = siz; buffer2[1] = siz;
} }
memcpy(buffer2 + 2, (char *) tns_packet_begin, sizeof(tns_packet_begin)); memcpy(buffer2 + 2, (char *)tns_packet_begin, sizeof(tns_packet_begin));
siz = strlen(connect_string); siz = strlen(connect_string);
if (siz > 255) { if (siz > 255) {
buffer2[2 + sizeof(tns_packet_begin)] = 1; buffer2[2 + sizeof(tns_packet_begin)] = 1;
@ -234,7 +234,7 @@ int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char o
} else { } else {
buffer2[1 + 2 + sizeof(tns_packet_begin)] = siz; buffer2[1 + 2 + sizeof(tns_packet_begin)] = siz;
} }
memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2, (char *) tns_packet_end, sizeof(tns_packet_end)); memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2, (char *)tns_packet_end, sizeof(tns_packet_end));
memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end), connect_string, strlen(connect_string)); memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end), connect_string, strlen(connect_string));
if (hydra_send(s, buffer2, 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string), 0) < 0) { if (hydra_send(s, buffer2, 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string), 0) < 0) {
return 1; return 1;
@ -257,7 +257,7 @@ int32_t start_oracle_listener(int32_t s, char *ip, int32_t port, unsigned char o
return 1; return 1;
} }
void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ORACLE, mysslport = PORT_ORACLE_SSL; int32_t myport = PORT_ORACLE, mysslport = PORT_ORACLE_SSL;
@ -283,10 +283,10 @@ void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -300,13 +300,15 @@ void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
/* run the cracking function */ /* run the cracking function */
next_run = start_oracle_listener(sock, ip, port, options, miscptr, fp); next_run = start_oracle_listener(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -324,13 +326,13 @@ void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *
} }
} }
int32_t service_oracle_listener_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_oracle_listener_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -338,8 +340,9 @@ int32_t service_oracle_listener_init(char *ip, int32_t sp, unsigned char options
return 0; return 0;
} }
void usage_oracle_listener(const char* service) { void usage_oracle_listener(const char *service) {
printf("Module oracle-listener / tns is optionally taking the mode the password is stored as, could be PLAIN (default) or CLEAR\n\n"); printf("Module oracle-listener / tns is optionally taking the mode the "
"password is stored as, could be PLAIN (default) or CLEAR\n\n");
} }
#endif #endif

View file

@ -11,30 +11,26 @@ find a big list on the Internet
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBOPENSSL #ifndef LIBOPENSSL
#include <stdio.h> #include <stdio.h>
void dummy_oracle_sid() { void dummy_oracle_sid() { printf("\n"); }
printf("\n");
}
#else #else
#include <openssl/des.h> #include <openssl/des.h>
#define HASHSIZE 16 #define HASHSIZE 16
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
unsigned char *hash; unsigned char *hash;
int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) {
/* /*
PP is the packet length PP is the packet length
XX is the length of connect data XX is the length of connect data
PP + tns_packet_begin + XX + tns_packet_end PP + tns_packet_begin + XX + tns_packet_end
*/ */
unsigned char tns_packet_begin[22] = { unsigned char tns_packet_begin[22] = {"\x00\x00\x01\x00\x00\x00\x01\x36\x01\x2c\x00\x00\x08\x00\x7f\xff\x86\x0e"
"\x00\x00\x01\x00\x00\x00\x01\x36\x01\x2c\x00\x00\x08\x00\x7f\xff\x86\x0e\x00\x00\x01\x00" "\x00\x00\x01\x00"};
}; unsigned char tns_packet_end[32] = {"\x00\x3a\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
unsigned char tns_packet_end[32] = { "\x00\x00\x09\x94\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00"};
"\x00\x3a\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x09\x94\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00"
};
char *empty = ""; char *empty = "";
char *login; char *login;
char connect_string[200]; char connect_string[200];
@ -47,8 +43,10 @@ int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char option
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
snprintf(connect_string, sizeof(connect_string), "(DESCRIPTION=(CONNECT_DATA=(SID=%s)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=)))(ADDRESS=(PROTOCOL=tcp)(HOST=%s)(PORT=%d)))", login, snprintf(connect_string, sizeof(connect_string),
hydra_address2string(ip), port); "(DESCRIPTION=(CONNECT_DATA=(SID=%s)(CID=(PROGRAM=)(HOST=__jdbc__)("
"USER=)))(ADDRESS=(PROTOCOL=tcp)(HOST=%s)(PORT=%d)))",
login, hydra_address2string(ip), port);
siz = 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string); siz = 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string);
if (siz > 255) { if (siz > 255) {
buffer2[0] = 1; buffer2[0] = 1;
@ -56,7 +54,7 @@ int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char option
} else { } else {
buffer2[1] = siz; buffer2[1] = siz;
} }
memcpy(buffer2 + 2, (char *) tns_packet_begin, sizeof(tns_packet_begin)); memcpy(buffer2 + 2, (char *)tns_packet_begin, sizeof(tns_packet_begin));
siz = strlen(connect_string); siz = strlen(connect_string);
if (siz > 255) { if (siz > 255) {
buffer2[2 + sizeof(tns_packet_begin)] = 1; buffer2[2 + sizeof(tns_packet_begin)] = 1;
@ -64,7 +62,7 @@ int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char option
} else { } else {
buffer2[1 + 2 + sizeof(tns_packet_begin)] = siz; buffer2[1 + 2 + sizeof(tns_packet_begin)] = siz;
} }
memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2, (char *) tns_packet_end, sizeof(tns_packet_end)); memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2, (char *)tns_packet_end, sizeof(tns_packet_end));
memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end), connect_string, strlen(connect_string)); memcpy(buffer2 + 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end), connect_string, strlen(connect_string));
if (hydra_send(s, buffer2, 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string), 0) < 0) { if (hydra_send(s, buffer2, 2 + sizeof(tns_packet_begin) + 2 + sizeof(tns_packet_end) + strlen(connect_string), 0) < 0) {
return 1; return 1;
@ -72,7 +70,8 @@ int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char option
if ((buf = hydra_receive_line(s)) == NULL) if ((buf = hydra_receive_line(s)) == NULL)
return 1; return 1;
//if no error reported. it should be a resend packet type 00 08 00 00 0b 00 00 00, 4 is refuse // if no error reported. it should be a resend packet type 00 08 00 00 0b 00
// 00 00, 4 is refuse
if ((strstr(buf, "ERR=") == NULL) && (buf[4] != 4)) { if ((strstr(buf, "ERR=") == NULL) && (buf[4] != 4)) {
hydra_report_found_host(port, ip, "oracle-sid", fp); hydra_report_found_host(port, ip, "oracle-sid", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
@ -85,7 +84,7 @@ int32_t start_oracle_sid(int32_t s, char *ip, int32_t port, unsigned char option
return 1; return 1;
} }
void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ORACLE, mysslport = PORT_ORACLE_SSL; int32_t myport = PORT_ORACLE, mysslport = PORT_ORACLE_SSL;
@ -94,10 +93,10 @@ void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscp
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -110,13 +109,15 @@ void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscp
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
/* run the cracking function */ /* run the cracking function */
next_run = start_oracle_sid(sock, ip, port, options, miscptr, fp); next_run = start_oracle_sid(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -134,13 +135,13 @@ void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscp
} }
} }
int32_t service_oracle_sid_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_oracle_sid_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -4,8 +4,8 @@ david: code is based on SNORT spo_database.c
tested with : tested with :
-instantclient_10_2 on Oracle 10.2.0 -instantclient_10_2 on Oracle 10.2.0
-instantclient-basic-linux.*-11.2.0.3.0.zip + instantclient-sdk-linux.*-11.2.0.3.0.zip -instantclient-basic-linux.*-11.2.0.3.0.zip +
on Oracle 9i and on Oracle 11g instantclient-sdk-linux.*-11.2.0.3.0.zip on Oracle 9i and on Oracle 11g
*/ */
@ -13,15 +13,15 @@ on Oracle 9i and on Oracle 11g
#ifndef LIBORACLE #ifndef LIBORACLE
void dummy_oracle() { void dummy_oracle() { printf("\n"); }
printf("\n");
}
#else #else
#include <oci.h> #include <oci.h>
#include <stdbool.h>
#include <sys/types.h> #include <sys/types.h>
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
OCIEnv *o_environment; OCIEnv *o_environment;
@ -40,7 +40,7 @@ void print_oracle_error(char *err) {
} }
} }
int32_t start_oracle(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_oracle(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[200], sid[100]; char *login, *pass, buffer[200], sid[100];
@ -55,14 +55,17 @@ int32_t start_oracle(int32_t s, char *ip, int32_t port, unsigned char options, c
/* /*
To use the Easy Connect naming method, PHP must be linked with Oracle 10g or greater Client libraries. To use the Easy Connect naming method, PHP must be linked with Oracle 10g
The Easy Connect string for Oracle 10g is of the form: [//]host_name[:port][/service_name]. or greater Client libraries. The Easy Connect string for Oracle 10g is of
With Oracle 11g, the syntax is: [//]host_name[:port][/service_name][:server_type][/instance_name]. the form: [//]host_name[:port][/service_name]. With Oracle 11g, the syntax
Service names can be found by running the Oracle utility lsnrctl status on the database server machine. is: [//]host_name[:port][/service_name][:server_type][/instance_name].
Service names can be found by running the Oracle utility lsnrctl status on
the database server machine.
The tnsnames.ora file can be in the Oracle Net search path, which includes $ORACLE_HOME/network/admin The tnsnames.ora file can be in the Oracle Net search path, which includes
and /etc. Alternatively set TNS_ADMIN so that $TNS_ADMIN/tnsnames.ora is read. Make sure the web $ORACLE_HOME/network/admin and /etc. Alternatively set TNS_ADMIN so that
daemon has read access to the file. $TNS_ADMIN/tnsnames.ora is read. Make sure the web daemon has read access
to the file.
*/ */
@ -78,61 +81,59 @@ int32_t start_oracle(int32_t s, char *ip, int32_t port, unsigned char options, c
print_oracle_error("OCIEnvInit 2"); print_oracle_error("OCIEnvInit 2");
return 4; return 4;
} }
if (OCIHandleAlloc(o_environment, (dvoid **) & o_error, OCI_HTYPE_ERROR, (size_t) 0, NULL)) { if (OCIHandleAlloc(o_environment, (dvoid **)&o_error, OCI_HTYPE_ERROR, (size_t)0, NULL)) {
print_oracle_error("OCIHandleAlloc"); print_oracle_error("OCIHandleAlloc");
return 4; return 4;
} }
if (OCILogon(o_environment, o_error, &o_servicecontext, (const OraText *) login, strlen(login), (const OraText *) pass, strlen(pass), (const OraText *) buffer, strlen(buffer))) { bool success = true;
if (OCILogon(o_environment, o_error, &o_servicecontext, (const OraText *)login, strlen(login), (const OraText *)pass, strlen(pass), (const OraText *)buffer, strlen(buffer))) {
success = false;
OCIErrorGet(o_error, 1, NULL, &o_errorcode, o_errormsg, sizeof(o_errormsg), OCI_HTYPE_ERROR); OCIErrorGet(o_error, 1, NULL, &o_errorcode, o_errormsg, sizeof(o_errormsg), OCI_HTYPE_ERROR);
//database: oracle_error: ORA-01017: invalid username/password; logon denied // database: oracle_error: ORA-01017: invalid username/password; logon
//database: oracle_error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor // denied database: oracle_error: ORA-12514: TNS:listener does not currently
//database: oracle_error: ORA-28000: the account is locked // know of service requested in connect descriptor database: oracle_error:
//Failed login attempts is set to 10 by default // ORA-28000: the account is locked Failed login attempts is set to 10 by
// default
if (verbose) { if (verbose) {
hydra_report(stderr, "[VERBOSE] database: oracle_error: %s\n", o_errormsg); hydra_report(stderr, "[VERBOSE] database: oracle_error: %s\n", o_errormsg);
} }
if (strstr((const char *) o_errormsg, "ORA-12514") != NULL) { if (strstr((const char *)o_errormsg, "ORA-12514") != NULL) {
hydra_report(stderr, "[ERROR] ORACLE SID is not valid, you should try to enumerate them.\n"); hydra_report(stderr, "[ERROR] ORACLE SID is not valid, you should try to "
"enumerate them.\n");
hydra_completed_pair(); hydra_completed_pair();
return 3; return 3;
} }
if (strstr((const char *) o_errormsg, "ORA-28000") != NULL) { if (strstr((const char *)o_errormsg, "ORA-28000") != NULL) {
hydra_report(stderr, "[INFO] ORACLE account %s is locked.\n", login); hydra_report(stderr, "[INFO] ORACLE account %s is locked.\n", login);
hydra_completed_pair_skip(); hydra_completed_pair_skip();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
return 2; return 2;
} }
// ORA-28002: the password will expire within 7 days
if (o_error) { if (strstr((const char *)o_errormsg, "ORA-28002") != NULL) {
OCIHandleFree((dvoid *) o_error, OCI_HTYPE_ERROR); hydra_report(stderr, "[INFO] ORACLE account %s password will expire soon.\n", login);
success = true;
} }
}
hydra_completed_pair(); if (success) {
//by default, set in sqlnet.ora, the trace file is generated in pwd to log any errors happening,
//as we don't care, we are deleting the file
//set these parameters to not generate the file
//LOG_DIRECTORY_CLIENT = /dev/null
//LOG_FILE_CLIENT = /dev/null
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3;
return 2;
} else {
OCILogoff(o_servicecontext, o_error); OCILogoff(o_servicecontext, o_error);
if (o_error) {
OCIHandleFree((dvoid *) o_error, OCI_HTYPE_ERROR);
}
hydra_report_found_host(port, ip, "oracle", fp); hydra_report_found_host(port, ip, "oracle", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
} else {
hydra_completed_pair();
}
if (o_error) {
OCIHandleFree((dvoid *)o_error, OCI_HTYPE_ERROR);
} }
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
return 1; return success ? 1 : 2;
} }
void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_ORACLE; int32_t myport = PORT_ORACLE;
@ -141,14 +142,14 @@ void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr,
return; return;
if ((miscptr == NULL) || (strlen(miscptr) == 0)) { if ((miscptr == NULL) || (strlen(miscptr) == 0)) {
//SID is required as miscptr // SID is required as miscptr
hydra_report(stderr, "[ERROR] Oracle SID is required, using ORCL as default\n"); hydra_report(stderr, "[ERROR] Oracle SID is required, using ORCL as default\n");
miscptr = "ORCL"; miscptr = "ORCL";
} }
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if (port != 0) if (port != 0)
@ -158,18 +159,24 @@ void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr,
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: case 2:
next_run = start_oracle(sock, ip, port, options, miscptr, fp); next_run = start_oracle(sock, ip, port, options, miscptr, fp);
hydra_child_exit(0); if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// by default, set in sqlnet.ora, the trace file is generated in pwd to log
// any errors happening, as we don't care, we are deleting the file set
// these parameters to not generate the file LOG_DIRECTORY_CLIENT =
// /dev/null LOG_FILE_CLIENT = /dev/null
unlink("sqlnet.log"); unlink("sqlnet.log");
hydra_child_exit(0); hydra_child_exit(0);
return; return;
@ -183,13 +190,13 @@ void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr,
#endif #endif
int32_t service_oracle_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_oracle_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -197,6 +204,7 @@ int32_t service_oracle_init(char *ip, int32_t sp, unsigned char options, char *m
return 0; return 0;
} }
void usage_oracle(const char* service) { void usage_oracle(const char *service) {
printf("Module oracle / ora is optionally taking the ORACLE SID, default is \"ORCL\"\n\n"); printf("Module oracle / ora is optionally taking the ORACLE SID, default is "
"\"ORCL\"\n\n");
} }

View file

@ -1,6 +1,6 @@
//This plugin was written by <david dot maciejak at kyxar dot fr> // This plugin was written by <david dot maciejak at kyxar dot fr>
// //
//PC-Anywhere authentication protocol test on Symantec PC-Anywhere 10.5 // PC-Anywhere authentication protocol test on Symantec PC-Anywhere 10.5
// //
// no memleaks found on 110425 // no memleaks found on 110425
@ -71,7 +71,6 @@ void pca_encrypt(char *cleartxt) {
passwd[strlen(passwd)] = '\0'; passwd[strlen(passwd)] = '\0';
strcpy(cleartxt, passwd); strcpy(cleartxt, passwd);
} }
} }
void pca_decrypt(char *password) { void pca_decrypt(char *password) {
@ -92,7 +91,7 @@ void debugprintf(char *msg) {
printf("debug: %s\n", msg); printf("debug: %s\n", msg);
} }
int32_t start_pcanywhere(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_pcanywhere(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
char buffer[2048] = ""; char buffer[2048] = "";
@ -119,7 +118,6 @@ int32_t start_pcanywhere(int32_t s, char *ip, int32_t port, unsigned char option
server[3] = "Enter login name"; server[3] = "Enter login name";
server[4] = "denying connection"; server[4] = "denying connection";
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
@ -158,13 +156,15 @@ int32_t start_pcanywhere(int32_t s, char *ip, int32_t port, unsigned char option
if (i == 0 || i == 3) if (i == 0 || i == 3)
clean_buffer(buffer, ret); clean_buffer(buffer, ret);
if (debug) show_buffer(buffer, ret); if (debug)
show_buffer(buffer, ret);
if (i == 2) { if (i == 2) {
clean_buffer(buffer, ret); clean_buffer(buffer, ret);
buffer[sizeof(buffer) - 1] = 0; buffer[sizeof(buffer) - 1] = 0;
if (strstr(buffer, server[i + 2]) != NULL) { if (strstr(buffer, server[i + 2]) != NULL) {
fprintf(stderr, "[ERROR] PC Anywhere host denying connection because you have requested a lower encrypt level\n"); fprintf(stderr, "[ERROR] PC Anywhere host denying connection because "
"you have requested a lower encrypt level\n");
return 3; return 3;
} }
} }
@ -224,7 +224,7 @@ int32_t start_pcanywhere(int32_t s, char *ip, int32_t port, unsigned char option
return 1; return 1;
} }
void service_pcanywhere(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_pcanywhere(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_PCANYWHERE, mysslport = PORT_PCANYWHERE_SSL; int32_t myport = PORT_PCANYWHERE, mysslport = PORT_PCANYWHERE_SSL;
@ -233,9 +233,8 @@ void service_pcanywhere(char *ip, int32_t sp, unsigned char options, char *miscp
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
usleepn(275); usleepn(275);
@ -251,7 +250,8 @@ void service_pcanywhere(char *ip, int32_t sp, unsigned char options, char *miscp
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -278,13 +278,13 @@ void service_pcanywhere(char *ip, int32_t sp, unsigned char options, char *miscp
} }
} }
int32_t service_pcanywhere_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_pcanywhere_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -5,11 +5,11 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
#define LEN_HDR_RPC 24 #define LEN_HDR_RPC 24
#define LEN_AUTH_UNIX 72+12 #define LEN_AUTH_UNIX 72 + 12
/* RPC common hdr */ /* RPC common hdr */
struct rpc_hdr { /* 24 */ struct rpc_hdr { /* 24 */
unsigned long xid; unsigned long xid;
unsigned long type_msg; unsigned long type_msg;
unsigned long version_rpc; unsigned long version_rpc;
@ -29,11 +29,11 @@ struct pr_auth_args {
char comments[255]; char comments[255];
}; };
#define LEN_HDR_PCN_AUTH sizeof(struct pr_auth_args) #define LEN_HDR_PCN_AUTH sizeof(struct pr_auth_args)
/* Lets start ... */ /* Lets start ... */
int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[LEN_HDR_RPC + LEN_AUTH_UNIX + LEN_HDR_PCN_AUTH]; char *login, *pass, buffer[LEN_HDR_RPC + LEN_AUTH_UNIX + LEN_HDR_PCN_AUTH];
char *ptr, *pkt = buffer; char *ptr, *pkt = buffer;
@ -51,22 +51,24 @@ int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, ch
memset(pkt, 0, sizeof(buffer)); memset(pkt, 0, sizeof(buffer));
rpch = (struct rpc_hdr *) (pkt); rpch = (struct rpc_hdr *)(pkt);
authp = (unsigned long *) (pkt + LEN_HDR_RPC); authp = (unsigned long *)(pkt + LEN_HDR_RPC);
prh = (struct pr_auth_args *) (pkt + LEN_HDR_RPC + LEN_AUTH_UNIX); prh = (struct pr_auth_args *)(pkt + LEN_HDR_RPC + LEN_AUTH_UNIX);
rpch->xid = htonl(0x32544843); rpch->xid = htonl(0x32544843);
rpch->type_msg = htonl(0); rpch->type_msg = htonl(0);
rpch->version_rpc = htonl(2); rpch->version_rpc = htonl(2);
rpch->prog_id = htonl(150001); rpch->prog_id = htonl(150001);
rpch->prog_ver = htonl(2); rpch->prog_ver = htonl(2);
rpch->prog_proc = htonl(13); /* PCNFSD_PROC_PRAUTH */ rpch->prog_proc = htonl(13); /* PCNFSD_PROC_PRAUTH */
prh->len_clnt = htonl(63); prh->len_clnt = htonl(63);
prh->len_id = htonl(31); prh->len_id = htonl(31);
prh->len_passwd = htonl(63); prh->len_passwd = htonl(63);
prh->len_comments = htonl(254); prh->len_comments = htonl(254);
strcpy(prh->comments, " Hydra - THC password cracker - visit https://github.com/vanhauser-thc/thc-hydra - use only allowed for legal purposes "); strcpy(prh->comments, " Hydra - THC password cracker - visit "
"https://github.com/vanhauser-thc/thc-hydra - use only "
"allowed for legal purposes ");
strcpy(prh->name, "localhost"); strcpy(prh->name, "localhost");
ptr = prh->id; ptr = prh->id;
@ -82,16 +84,16 @@ int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, ch
} }
*ptr = 0; *ptr = 0;
gettimeofday(&tv, (struct timezone *) NULL); gettimeofday(&tv, (struct timezone *)NULL);
*(authp) = htonl(1); /* auth unix */ *(authp) = htonl(1); /* auth unix */
*(++authp) = htonl(LEN_AUTH_UNIX - 16); /* length auth */ *(++authp) = htonl(LEN_AUTH_UNIX - 16); /* length auth */
*(++authp) = htonl(tv.tv_sec); /* local time */ *(++authp) = htonl(tv.tv_sec); /* local time */
*(++authp) = htonl(9); /* length host */ *(++authp) = htonl(9); /* length host */
strcpy((char *) ++authp, "localhost"); /* hostname */ strcpy((char *)++authp, "localhost"); /* hostname */
authp += (3); /* len(host)%4 */ authp += (3); /* len(host)%4 */
*(authp) = htonl(0); /* uid root */ *(authp) = htonl(0); /* uid root */
*(++authp) = htonl(0); /* gid root */ *(++authp) = htonl(0); /* gid root */
*(++authp) = htonl(9); /* 9 gid grps */ *(++authp) = htonl(9); /* 9 gid grps */
/* group root, bin, daemon, sys, adm, disk, wheel, floppy, "user gid" */ /* group root, bin, daemon, sys, adm, disk, wheel, floppy, "user gid" */
*(++authp) = htonl(0); *(++authp) = htonl(0);
*(++authp) = htonl(1); *(++authp) = htonl(1);
@ -113,7 +115,7 @@ int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
/* analyze the output */ /* analyze the output */
if (buf[2] != 'g' || buf[5] != 32) { if (buf[2] != 'g' || buf[5] != 32) {
fprintf(stderr, "[ERROR] RPC answer status : bad proc/version/auth\n"); fprintf(stderr, "[ERROR] RPC answer status : bad proc/version/auth\n");
free(buf); free(buf);
@ -136,7 +138,7 @@ int32_t start_pcnfs(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_pcnfs(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_pcnfs(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
hydra_register_socket(sp); hydra_register_socket(sp);
@ -155,22 +157,23 @@ void service_pcnfs(char *ip, int32_t sp, unsigned char options, char *miscptr, F
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((sock = hydra_connect_udp(ip, port)) < 0) { if ((sock = hydra_connect_udp(ip, port)) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
hydra_child_exit(1); fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
} hydra_child_exit(1);
next_run = 2;
break;
} }
case 2: /* run the cracking function */ next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_pcnfs(sock, ip, port, options, miscptr, fp); next_run = start_pcnfs(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -183,13 +186,13 @@ void service_pcnfs(char *ip, int32_t sp, unsigned char options, char *miscptr, F
} }
} }
int32_t service_pcnfs_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_pcnfs_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -1,12 +1,12 @@
#include "hydra-mod.h" #include "hydra-mod.h"
#include "sasl.h" #include "sasl.h"
//openssl s_client -starttls pop3 -crlf -connect 192.168.0.10:110 // openssl s_client -starttls pop3 -crlf -connect 192.168.0.10:110
typedef struct pool_str { typedef struct pool_str {
char ip[36]; char ip[36];
/* int32_t port;*/// not needed /* int32_t port;*/ // not needed
int32_t pop3_auth_mechanism; int32_t pop3_auth_mechanism;
int32_t disable_tls; int32_t disable_tls;
struct pool_str *next; struct pool_str *next;
@ -18,7 +18,7 @@ char apop_challenge[300] = "";
pool *plist = NULL, *p = NULL; pool *plist = NULL, *p = NULL;
/* functions */ /* functions */
int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname); int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname);
pool *list_create(pool data) { pool *list_create(pool data) {
pool *p; pool *p;
@ -27,7 +27,7 @@ pool *list_create(pool data) {
return NULL; return NULL;
memcpy(p->ip, data.ip, 36); memcpy(p->ip, data.ip, 36);
//p->port = data.port; // p->port = data.port;
p->pop3_auth_mechanism = data.pop3_auth_mechanism; p->pop3_auth_mechanism = data.pop3_auth_mechanism;
p->disable_tls = data.disable_tls; p->disable_tls = data.disable_tls;
p->next = NULL; p->next = NULL;
@ -40,7 +40,7 @@ pool *list_insert(pool data) {
newnode = list_create(data); newnode = list_create(data);
newnode->next = plist; newnode->next = plist;
plist = newnode->next; // to be sure! plist = newnode->next; // to be sure!
return newnode; return newnode;
} }
@ -59,7 +59,7 @@ pool *list_find(char *ip) {
/* how to know when to release the mem ? /* how to know when to release the mem ?
-> well, after _start has determined which pool number it is */ -> well, after _start has determined which pool number it is */
int32_t list_remove(pool * node) { int32_t list_remove(pool *node) {
pool *save, *list = plist; pool *save, *list = plist;
int32_t ok = -1; int32_t ok = -1;
@ -88,18 +88,18 @@ char *pop3_read_server_capacity(int32_t sock) {
free(buf); free(buf);
ptr = buf = hydra_receive_line(sock); ptr = buf = hydra_receive_line(sock);
if (buf != NULL) { if (buf != NULL) {
/*
exchange capa:
/* +OK
exchange capa: UIDL
STLS
+OK */
UIDL
STLS
*/
if (strstr(buf, "\r\n.\r\n") != NULL && buf[0] == '+') { if (strstr(buf, "\r\n.\r\n") != NULL && buf[0] == '+') {
resp = 1; resp = 1;
/* we got the capability info then get the completed warning info from server */ /* we got the capability info then get the completed warning info from
* server */
while (hydra_data_ready(sock)) { while (hydra_data_ready(sock)) {
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
@ -109,7 +109,7 @@ STLS
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r') if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (*(ptr) == '.' || *(ptr) == '-') if (buf[strlen(buf) - 1] == '.' || *(ptr) == '.' || *(ptr) == '-')
resp = 1; resp = 1;
} }
} }
@ -117,8 +117,8 @@ STLS
return buf; return buf;
} }
int32_t start_pop3(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_pop3(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\""; char *empty = "\"\"", *result = NULL;
char *login, *pass, buffer[500], buffer2[500], *fooptr; char *login, *pass, buffer[500], buffer2[500], *fooptr;
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
@ -134,235 +134,234 @@ int32_t start_pop3(int32_t s, char *ip, int32_t port, unsigned char options, cha
switch (p->pop3_auth_mechanism) { switch (p->pop3_auth_mechanism) {
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_APOP:{ case AUTH_APOP: {
MD5_CTX c; MD5_CTX c;
unsigned char md5_raw[MD5_DIGEST_LENGTH]; unsigned char md5_raw[MD5_DIGEST_LENGTH];
int32_t i; int32_t i;
char *pbuffer = buffer2; char *pbuffer = buffer2;
MD5_Init(&c); MD5_Init(&c);
MD5_Update(&c, apop_challenge, strlen(apop_challenge)); MD5_Update(&c, apop_challenge, strlen(apop_challenge));
MD5_Update(&c, pass, strlen(pass)); MD5_Update(&c, pass, strlen(pass));
MD5_Final(md5_raw, &c); MD5_Final(md5_raw, &c);
for (i = 0; i < MD5_DIGEST_LENGTH; i++) { for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(pbuffer, "%02x", md5_raw[i]); sprintf(pbuffer, "%02x", md5_raw[i]);
pbuffer += 2; pbuffer += 2;
}
sprintf(buffer, "APOP %s %s\r\n", login, buffer2);
} }
break; sprintf(buffer, "APOP %s %s\r\n", login, buffer2);
} break;
#endif #endif
case AUTH_LOGIN:{ case AUTH_LOGIN: {
sprintf(buffer, "AUTH LOGIN\r\n"); sprintf(buffer, "AUTH LOGIN\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1; return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 LOGIN AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
strcpy(buffer2, login);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 LOGIN AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
strcpy(buffer2, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2);
} }
break; if ((buf = hydra_receive_line(s)) == NULL)
return 4;
case AUTH_PLAIN:{ if (buf[0] != '+') {
sprintf(buffer, "AUTH PLAIN\r\n"); hydra_report(stderr, "[ERROR] POP3 LOGIN AUTH : %s\n", buf);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 PLAIN AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf); free(buf);
return 3;
memset(buffer, 0, sizeof(buffer));
sasl_plain(buffer, login, pass);
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
} }
break; free(buf);
strcpy(buffer2, login);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 LOGIN AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
strcpy(buffer2, pass);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2);
} break;
case AUTH_PLAIN: {
sprintf(buffer, "AUTH PLAIN\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 PLAIN AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf);
memset(buffer, 0, sizeof(buffer));
result = sasl_plain(buffer, login, pass);
if (result == NULL)
return 3;
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
} break;
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_CRAMMD5: case AUTH_CRAMMD5:
case AUTH_CRAMSHA1: case AUTH_CRAMSHA1:
case AUTH_CRAMSHA256:{ case AUTH_CRAMSHA256: {
int32_t rc = 0; int32_t rc = 0;
char *preplogin; char *preplogin;
rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin); rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) { if (rc) {
return 3; return 3;
} }
switch (p->pop3_auth_mechanism) {
case AUTH_CRAMMD5:
sprintf(buffer, "AUTH CRAM-MD5\r\n");
break;
case AUTH_CRAMSHA1:
sprintf(buffer, "AUTH CRAM-SHA1\r\n");
break;
case AUTH_CRAMSHA256:
sprintf(buffer, "AUTH CRAM-SHA256\r\n");
break;
}
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
// get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
switch (p->pop3_auth_mechanism) { switch (p->pop3_auth_mechanism) {
case AUTH_CRAMMD5: case AUTH_CRAMMD5:
sprintf(buffer, "AUTH CRAM-MD5\r\n"); hydra_report(stderr, "[ERROR] POP3 CRAM-MD5 AUTH : %s\n", buf);
break; break;
case AUTH_CRAMSHA1: case AUTH_CRAMSHA1:
sprintf(buffer, "AUTH CRAM-SHA1\r\n"); hydra_report(stderr, "[ERROR] POP3 CRAM-SHA1 AUTH : %s\n", buf);
break; break;
case AUTH_CRAMSHA256: case AUTH_CRAMSHA256:
sprintf(buffer, "AUTH CRAM-SHA256\r\n"); hydra_report(stderr, "[ERROR] POP3 CRAM-SHA256 AUTH : %s\n", buf);
break; break;
} }
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
//get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
switch (p->pop3_auth_mechanism) {
case AUTH_CRAMMD5:
hydra_report(stderr, "[ERROR] POP3 CRAM-MD5 AUTH : %s\n", buf);
break;
case AUTH_CRAMSHA1:
hydra_report(stderr, "[ERROR] POP3 CRAM-SHA1 AUTH : %s\n", buf);
break;
case AUTH_CRAMSHA256:
hydra_report(stderr, "[ERROR] POP3 CRAM-SHA256 AUTH : %s\n", buf);
break;
}
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 2);
free(buf); free(buf);
return 3;
memset(buffer2, 0, sizeof(buffer2));
switch (p->pop3_auth_mechanism) {
case AUTH_CRAMMD5:{
sasl_cram_md5(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
case AUTH_CRAMSHA1:{
sasl_cram_sha1(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
case AUTH_CRAMSHA256:{
sasl_cram_sha256(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
}
break;
}
hydra_tobase64((unsigned char *) buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} }
break;
case AUTH_DIGESTMD5:{ memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "AUTH DIGEST-MD5\r\n"); from64tobits((char *)buffer, buf + 2);
free(buf);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) memset(buffer2, 0, sizeof(buffer2));
return 1;
//receive switch (p->pop3_auth_mechanism) {
if ((buf = hydra_receive_line(s)) == NULL) case AUTH_CRAMMD5: {
return 4; result = sasl_cram_md5(buffer2, pass, buffer);
if (buf[0] != '+') { if (result == NULL)
hydra_report(stderr, "[ERROR] POP3 DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3; return 3;
} sprintf(buffer, "%s %.250s", preplogin, buffer2);
memset(buffer, 0, sizeof(buffer)); } break;
from64tobits((char *) buffer, buf); case AUTH_CRAMSHA1: {
result = sasl_cram_sha1(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
} break;
case AUTH_CRAMSHA256: {
result = sasl_cram_sha256(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
} break;
}
hydra_tobase64((unsigned char *)buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} break;
case AUTH_DIGESTMD5: {
sprintf(buffer, "AUTH DIGEST-MD5\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
// receive
if ((buf = hydra_receive_line(s)) == NULL)
return 4;
if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 DIGEST-MD5 AUTH : %s\n", buf);
free(buf); free(buf);
return 3;
if (debug)
hydra_report(stderr, "[DEBUG] S: %s\n", buffer);
fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "pop", NULL, 0, NULL);
if (fooptr == NULL)
return 3;
if (debug)
hydra_report(stderr, "[DEBUG] C: %s\n", buffer2);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} }
break; memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf);
free(buf);
if (debug)
hydra_report(stderr, "[DEBUG] S: %s\n", buffer);
fooptr = buffer2;
result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "pop", NULL, 0, NULL);
if (result == NULL)
return 3;
if (debug)
hydra_report(stderr, "[DEBUG] C: %s\n", buffer2);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} break;
#endif #endif
case AUTH_NTLM:{ case AUTH_NTLM: {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
//Send auth request // Send auth request
sprintf(buffer, "AUTH NTLM\r\n"); sprintf(buffer, "AUTH NTLM\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1; return 1;
//receive // receive
if ((buf = hydra_receive_line(s)) == NULL) if ((buf = hydra_receive_line(s)) == NULL)
return 4; return 4;
if (buf[0] != '+') { if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] POP3 NTLM AUTH : %s\n", buf); hydra_report(stderr, "[ERROR] POP3 NTLM AUTH : %s\n", buf);
free(buf);
return 3;
}
free(buf); free(buf);
//send auth and receive challenge return 3;
//send auth request: lst the server send it's own hostname and domainname
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2));
sprintf(buffer, "%s\r\n", buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
if ((buf = hydra_receive_line(s)) == NULL || strlen(buf) < 6)
return 4;
//recover challenge
from64tobits((char *) buf1, buf + 2);
free(buf);
//Send response
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2));
sprintf(buffer, "%s\r\n", buf1);
} }
break; free(buf);
// send auth and receive challenge
// send auth request: lst the server send it's own hostname and domainname
buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
sprintf(buffer, "%s\r\n", buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
if ((buf = hydra_receive_line(s)) == NULL || strlen(buf) < 6)
return 4;
// recover challenge
from64tobits((char *)buf1, buf + 2);
free(buf);
// Send response
buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "%s\r\n", buf1);
} break;
default: default:
sprintf(buffer, "USER %.250s\r\n", login); sprintf(buffer, "USER %.250s\r\n", login);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -413,11 +412,11 @@ int32_t start_pop3(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 2; return 2;
} }
void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
char *ptr = NULL; char *ptr = NULL;
//extract data from the pool, ip is the key // extract data from the pool, ip is the key
if (plist == NULL) if (plist == NULL)
if (service_pop3_init(ip, sp, options, miscptr, fp, port, hostname) != 0) if (service_pop3_init(ip, sp, options, miscptr, fp, port, hostname) != 0)
hydra_child_exit(2); hydra_child_exit(2);
@ -433,10 +432,9 @@ void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
@ -448,11 +446,11 @@ void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '+') { /* check the first line */ if (buf == NULL || buf[0] != '+') { /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an POP3 protocol or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] Not an POP3 protocol or service shutdown: %s\n", buf);
hydra_child_exit(2); hydra_child_exit(2);
@ -470,11 +468,13 @@ void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (!p->disable_tls) { if (!p->disable_tls) {
/* check for STARTTLS, if available we may have access to more basic auth methods */ /* check for STARTTLS, if available we may have access to more basic
* auth methods */
hydra_send(sock, "STLS\r\n", strlen("STLS\r\n"), 0); hydra_send(sock, "STLS\r\n", strlen("STLS\r\n"), 0);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf[0] != '+') { if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer received from STARTTLS request\n"); hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer "
"received from STARTTLS request\n");
} else { } else {
free(buf); free(buf);
if ((hydra_connect_to_ssl(sock, hostname) == -1)) { if ((hydra_connect_to_ssl(sock, hostname) == -1)) {
@ -491,15 +491,15 @@ void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_pop3(sock, ip, port, options, miscptr, fp); next_run = start_pop3(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 4: /* clean exit */ case 4: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -512,8 +512,7 @@ void service_pop3(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
int32_t myport = PORT_POP3, mysslport = PORT_POP3_SSL; int32_t myport = PORT_POP3, mysslport = PORT_POP3_SSL;
char *ptr = NULL; char *ptr = NULL;
int32_t sock = -1; int32_t sock = -1;
@ -523,6 +522,7 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
p.pop3_auth_mechanism = AUTH_CLEAR; p.pop3_auth_mechanism = AUTH_CLEAR;
p.disable_tls = 1; p.disable_tls = 1;
p.next = NULL;
memcpy(p.ip, ip, 36); memcpy(p.ip, ip, 36);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -536,11 +536,11 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] pid %d terminating, can not connect\n", (int32_t)getpid());
return -1; return -1;
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '+') { /* check the first line */ if (buf == NULL || buf[0] != '+') { /* check the first line */
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Not an POP3 protocol or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] Not an POP3 protocol or service shutdown: %s\n", buf);
return -1; return -1;
@ -574,7 +574,7 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
int32_t i; int32_t i;
for (i = 0; i < strlen(miscptr); i++) for (i = 0; i < strlen(miscptr); i++)
miscptr[i] = (char) toupper((int32_t) miscptr[i]); miscptr[i] = (char)toupper((int32_t)miscptr[i]);
if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) { if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) {
p.disable_tls = 0; p.disable_tls = 0;
@ -583,13 +583,15 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (!p.disable_tls) { if (!p.disable_tls) {
/* check for STARTTLS, if available we may have access to more basic auth methods */ /* check for STARTTLS, if available we may have access to more basic auth
* methods */
if (strstr(buf, "STLS") != NULL) { if (strstr(buf, "STLS") != NULL) {
hydra_send(sock, "STLS\r\n", strlen("STLS\r\n"), 0); hydra_send(sock, "STLS\r\n", strlen("STLS\r\n"), 0);
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf[0] != '+') { if (buf[0] != '+') {
hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer received from STARTTLS request\n"); hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer "
"received from STARTTLS request\n");
} else { } else {
free(buf); free(buf);
if ((hydra_connect_to_ssl(sock, hostname) == -1)) { if ((hydra_connect_to_ssl(sock, hostname) == -1)) {
@ -615,16 +617,16 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
} }
} }
} else } else
hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is not supported by the server\n"); hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is not "
"supported by the server\n");
} }
#endif #endif
if (hydra_send(sock, quit_str, strlen(quit_str), 0) < 0) { if (hydra_send(sock, quit_str, strlen(quit_str), 0) < 0) {
//we don't care if the server is not receiving the quit msg // we don't care if the server is not receiving the quit msg
} }
hydra_disconnect(sock); hydra_disconnect(sock);
if (verbose) if (verbose)
hydra_report(stderr, "[VERBOSE] CAPABILITY: %s", buf); hydra_report(stderr, "[VERBOSE] CAPABILITY: %s", buf);
@ -647,7 +649,8 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
which are supported. which are supported.
*/ */
/* which mean threre will *always* have a space before the LOGIN auth keyword */ /* which mean threre will *always* have a space before the LOGIN auth keyword
*/
if ((strstr(buf, " LOGIN") == NULL) && (strstr(buf, "NTLM") != NULL)) { if ((strstr(buf, " LOGIN") == NULL) && (strstr(buf, "NTLM") != NULL)) {
p.pop3_auth_mechanism = AUTH_NTLM; p.pop3_auth_mechanism = AUTH_NTLM;
} }
@ -687,12 +690,10 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
#else #else
p.pop3_auth_mechanism = AUTH_CLEAR; p.pop3_auth_mechanism = AUTH_CLEAR;
#endif #endif
} }
free(buf); free(buf);
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
if (strstr(miscptr, "CLEAR")) if (strstr(miscptr, "CLEAR"))
p.pop3_auth_mechanism = AUTH_CLEAR; p.pop3_auth_mechanism = AUTH_CLEAR;
@ -721,7 +722,6 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
if (strstr(miscptr, "NTLM")) if (strstr(miscptr, "NTLM"))
p.pop3_auth_mechanism = AUTH_NTLM; p.pop3_auth_mechanism = AUTH_NTLM;
} }
if (verbose) { if (verbose) {
@ -764,7 +764,6 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
case AUTH_NTLM: case AUTH_NTLM:
hydra_report(stderr, "[VERBOSE] using POP3 NTLM AUTH mechanism\n"); hydra_report(stderr, "[VERBOSE] using POP3 NTLM AUTH mechanism\n");
break; break;
} }
} }
@ -776,8 +775,11 @@ int32_t service_pop3_init(char *ip, int32_t sp, unsigned char options, char *mis
return 0; return 0;
} }
void usage_pop3(const char* service) { void usage_pop3(const char *service) {
printf("Module pop3 is optionally taking one authentication type of:\n" printf("Module pop3 is optionally taking one authentication type of:\n"
" CLEAR (default), LOGIN, PLAIN, CRAM-MD5, CRAM-SHA1,\n" " CLEAR (default), LOGIN, PLAIN, CRAM-MD5, CRAM-SHA1,\n"
" CRAM-SHA256, DIGEST-MD5, NTLM.\n" "Additionally TLS encryption via STLS can be enforced with the TLS option.\n\n" "Example: pop3://target/TLS:PLAIN\n"); " CRAM-SHA256, DIGEST-MD5, NTLM.\n"
"Additionally TLS encryption via STLS can be enforced with the TLS "
"option.\n\n"
"Example: pop3://target/TLS:PLAIN\n");
} }

View file

@ -1,26 +1,25 @@
/* /*
* PostgresSQL Support - by Diaul (at) devilopers.org * PostgresSQL Support - by Diaul (at) devilopers.org
*
* *
*
* 110425 no obvious memleaks found * 110425 no obvious memleaks found
*/ */
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBPOSTGRES #ifndef LIBPOSTGRES
void dummy_postgres() { void dummy_postgres() { printf("\n"); }
printf("\n");
}
#else #else
#include "libpq-fe.h" // Postgres connection functions #include "libpq-fe.h" // Postgres connection functions
#include <stdio.h> #include <stdio.h>
#define DEFAULT_DB "template1" #define DEFAULT_DB "template1"
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
int32_t start_postgres(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_postgres(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
char database[256]; char database[256];
@ -42,8 +41,7 @@ int32_t start_postgres(int32_t s, char *ip, int32_t port, unsigned char options,
* Building the connection string * Building the connection string
*/ */
snprintf(connection_string, sizeof(connection_string), "host = '%s' port = '%d' dbname = '%s' user = '%s' password = '%s' ", hydra_address2string(ip), port, database, login, pass);
snprintf(connection_string, sizeof(connection_string), "host = '%s' dbname = '%s' user = '%s' password = '%s' ", hydra_address2string(ip), database, login, pass);
if (verbose) if (verbose)
hydra_report(stderr, "connection string: %s\n", connection_string); hydra_report(stderr, "connection string: %s\n", connection_string);
@ -65,7 +63,7 @@ int32_t start_postgres(int32_t s, char *ip, int32_t port, unsigned char options,
return 1; return 1;
} }
void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_POSTGRES, mysslport = PORT_POSTGRES_SSL; int32_t myport = PORT_POSTGRES, mysslport = PORT_POSTGRES_SSL;
@ -74,12 +72,11 @@ void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -92,16 +89,19 @@ void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); if (quiet != 1)
fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: case 2:
/* /*
* Here we start the password cracking process * Here we start the password cracking process
*/ */
next_run = start_postgres(sock, ip, port, options, miscptr, fp); next_run = start_postgres(sock, ip, port, options, miscptr, fp);
if ((next_run == 2 || next_run == 1) && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: case 3:
if (sock >= 0) if (sock >= 0)
@ -118,13 +118,13 @@ void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr
#endif #endif
int32_t service_postgres_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_postgres_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -132,6 +132,7 @@ int32_t service_postgres_init(char *ip, int32_t sp, unsigned char options, char
return 0; return 0;
} }
void usage_postgres(const char* service) { void usage_postgres(const char *service) {
printf("Module postgres is optionally taking the database to attack, default is \"template1\"\n\n"); printf("Module postgres is optionally taking the database to attack, default "
"is \"template1\"\n\n");
} }

View file

@ -7,42 +7,42 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
//RAdmin 2.x // RAdmin 2.x
struct rmessage { struct rmessage {
uint8_t magic; //Indicates version, probably? uint8_t magic; // Indicates version, probably?
uint32_t length; //Total message size of data. uint32_t length; // Total message size of data.
uint32_t checksum; //Checksum from type to end of data. uint32_t checksum; // Checksum from type to end of data.
uint8_t type; //Command type, table below. uint8_t type; // Command type, table below.
unsigned char data[32]; //data to be sent. unsigned char data[32]; // data to be sent.
}; };
/* /*
* Usage: sum = checksum(message); * Usage: sum = checksum(message);
* Function: Returns a 4 byte little endian sum of the messages typecode+data. This data is zero padded for alignment. * Function: Returns a 4 byte little endian sum of the messages typecode+data.
* Example message (big endian): * This data is zero padded for alignment. Example message (big endian):
* [01][00000021][0f43d461] sum([1b6e779a f37189bb c1b22982 c80d1f4d 66678ff9 4b10f0ce eabff6e8 f4fb8338 3b] + zeropad(3)]) * [01][00000021][0f43d461] sum([1b6e779a f37189bb c1b22982 c80d1f4d 66678ff9
* Sum: is 0f43d461 (big endian) * 4b10f0ce eabff6e8 f4fb8338 3b] + zeropad(3)]) Sum: is 0f43d461 (big endian)
*/ */
uint32_t checksum(struct rmessage *msg) { uint32_t checksum(struct rmessage *msg) {
int32_t blen; int32_t blen;
uint8_t *stream; uint8_t *stream;
uint32_t sum; uint32_t sum;
blen = msg->length; //Get the real length. blen = msg->length; // Get the real length.
blen += (4 - (blen % 4)); blen += (4 - (blen % 4));
//Allocate a worksapce. // Allocate a worksapce.
stream = calloc(blen, sizeof(uint8_t)); stream = calloc(blen, sizeof(uint8_t));
memcpy(stream, &msg->type, sizeof(uint8_t)); memcpy(stream, &msg->type, sizeof(uint8_t));
memcpy(stream+1, msg->data, blen-1); memcpy(stream + 1, msg->data, blen - 1);
sum = 0; sum = 0;
for(blen -= sizeof(uint32_t); blen > 0; blen -= sizeof(uint32_t)) { for (blen -= sizeof(uint32_t); blen > 0; blen -= sizeof(uint32_t)) {
sum += *(uint32_t *)(stream + blen); sum += *(uint32_t *)(stream + blen);
} }
sum += *(uint32_t *)stream; sum += *(uint32_t *)stream;
//Free the workspace. // Free the workspace.
free(stream); free(stream);
return sum; return sum;
@ -50,7 +50,8 @@ uint32_t checksum(struct rmessage *msg) {
/* /*
* Usage: challenge_request(message); * Usage: challenge_request(message);
* Function: Modifies message to reflect a request for a challenge. Updates the checksum as appropriate. * Function: Modifies message to reflect a request for a challenge. Updates the
* checksum as appropriate.
*/ */
void challenge_request(struct rmessage *msg) { void challenge_request(struct rmessage *msg) {
msg->magic = 0x01; msg->magic = 0x01;
@ -61,7 +62,8 @@ void challenge_request(struct rmessage *msg) {
/* /*
* Usage: challenge_request(message); * Usage: challenge_request(message);
* Function: Modifies message to reflect a response to a challenge. Updates the checksum as appropriate. * Function: Modifies message to reflect a response to a challenge. Updates the
* checksum as appropriate.
*/ */
void challenge_response(struct rmessage *msg, unsigned char *solution) { void challenge_response(struct rmessage *msg, unsigned char *solution) {
msg->magic = 0x01; msg->magic = 0x01;
@ -72,46 +74,47 @@ void challenge_response(struct rmessage *msg, unsigned char *solution) {
} }
/* /*
* Usage: buffer = message2buffer(message); send(buffer, message->length + 10); free(buffer) * Usage: buffer = message2buffer(message); send(buffer, message->length + 10);
* Function: Allocates a buffer for transmission and fills the buffer with message data such that it is ready to transmit. * free(buffer) Function: Allocates a buffer for transmission and fills the
* buffer with message data such that it is ready to transmit.
*/ */
//TODO: conver to a sendMessage() function? // TODO: conver to a sendMessage() function?
char *message2buffer(struct rmessage *msg) { char *message2buffer(struct rmessage *msg) {
char *data; char *data;
if(msg == NULL) { if (msg == NULL) {
hydra_report(stderr, "rmessage is null\n"); hydra_report(stderr, "rmessage is null\n");
hydra_child_exit(0); hydra_child_exit(0);
return NULL; return NULL;
} }
switch(msg->type) { switch (msg->type) {
case 0x1b: //Challenge request case 0x1b: // Challenge request
data = (char *)calloc (10, sizeof(char)); data = (char *)calloc(10, sizeof(char));
if(data == NULL) { if (data == NULL) {
hydra_report(stderr, "calloc failure\n"); hydra_report(stderr, "calloc failure\n");
hydra_child_exit(0);
}
memcpy(data, &msg->magic, sizeof(char));
*((int32_t *)(data+1)) = htonl(msg->length);
*((int32_t *)(data+5)) = htonl(msg->checksum);
memcpy((data+9), &msg->type, sizeof(char));
break;
case 0x09:
data = (char *)calloc (42, sizeof(char));
if(data == NULL) {
hydra_report(stderr, "calloc failure\n");
hydra_child_exit(0);
}
memcpy(data, &msg->magic, sizeof(char));
*((int32_t *)(data+1)) = htonl(msg->length);
*((int32_t *)(data+5)) = htonl(msg->checksum);
memcpy((data+9), &msg->type, sizeof(char));
memcpy((data+10), msg->data, sizeof(char) * 32);
break;
default:
hydra_report(stderr, "unknown rmessage type\n");
hydra_child_exit(0); hydra_child_exit(0);
return NULL; }
memcpy(data, &msg->magic, sizeof(char));
*((int32_t *)(data + 1)) = htonl(msg->length);
*((int32_t *)(data + 5)) = htonl(msg->checksum);
memcpy((data + 9), &msg->type, sizeof(char));
break;
case 0x09:
data = (char *)calloc(42, sizeof(char));
if (data == NULL) {
hydra_report(stderr, "calloc failure\n");
hydra_child_exit(0);
}
memcpy(data, &msg->magic, sizeof(char));
*((int32_t *)(data + 1)) = htonl(msg->length);
*((int32_t *)(data + 5)) = htonl(msg->checksum);
memcpy((data + 9), &msg->type, sizeof(char));
memcpy((data + 10), msg->data, sizeof(char) * 32);
break;
default:
hydra_report(stderr, "unknown rmessage type\n");
hydra_child_exit(0);
return NULL;
} }
return data; return data;
} }
@ -119,12 +122,12 @@ char *message2buffer(struct rmessage *msg) {
struct rmessage *buffer2message(char *buffer) { struct rmessage *buffer2message(char *buffer) {
struct rmessage *msg; struct rmessage *msg;
msg = calloc(1, sizeof(struct rmessage)); msg = calloc(1, sizeof(struct rmessage));
if(msg == NULL) { if (msg == NULL) {
hydra_report(stderr, "calloc failure\n"); hydra_report(stderr, "calloc failure\n");
hydra_child_exit(0); hydra_child_exit(0);
} }
//Start parsing... // Start parsing...
msg->magic = buffer[0]; msg->magic = buffer[0];
buffer += sizeof(char); buffer += sizeof(char);
msg->length = ntohl(*((uint32_t *)(buffer))); msg->length = ntohl(*((uint32_t *)(buffer)));
@ -134,41 +137,38 @@ struct rmessage *buffer2message(char *buffer) {
msg->type = buffer[0]; msg->type = buffer[0];
buffer += sizeof(char); buffer += sizeof(char);
//Verify known fields... // Verify known fields...
if(msg->magic != 0x01) { if (msg->magic != 0x01) {
hydra_report(stderr, "Bad magic\n"); hydra_report(stderr, "Bad magic\n");
hydra_child_exit(0); hydra_child_exit(0);
return NULL; return NULL;
} }
switch(msg->type) { switch (msg->type) {
case 0x1b: case 0x1b:
if(msg->length != 0x21) { if (msg->length != 0x21) {
hydra_report(stderr, "Bad length...%08x\n", msg->length); hydra_report(stderr, "Bad length...%08x\n", msg->length);
hydra_child_exit(0);
return NULL;
}
memcpy(msg->data, buffer, 32);
break;
case 0x0a:
//Win!
case 0x0b:
//Lose!
break;
default:
hydra_report(stderr, "unknown rmessage type");
hydra_child_exit(0); hydra_child_exit(0);
return NULL; return NULL;
}
memcpy(msg->data, buffer, 32);
break;
case 0x0a:
// Win!
case 0x0b:
// Lose!
break;
default:
hydra_report(stderr, "unknown rmessage type");
hydra_child_exit(0);
return NULL;
} }
return msg; return msg;
} }
int32_t start_radmin2(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) { return 0; }
int32_t start_radmin2(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
return 0;
}
void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
#ifdef HAVE_GCRYPT #ifdef HAVE_GCRYPT
int32_t sock = -1; int32_t sock = -1;
int32_t index; int32_t index;
@ -185,7 +185,7 @@ void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr,
gcry_cipher_hd_t cipher; gcry_cipher_hd_t cipher;
gcry_md_hd_t md; gcry_md_hd_t md;
if(port != 0) { if (port != 0) {
myport = port; myport = port;
} }
@ -193,14 +193,13 @@ void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr,
memset(buffer, 0x00, sizeof(buffer)); memset(buffer, 0x00, sizeof(buffer));
//Phone the mother ship // Phone the mother ship
hydra_register_socket(sp); hydra_register_socket(sp);
if( memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) { if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
return; return;
} }
while(1) { while (1) {
/* Typical conversation goes as follows... /* Typical conversation goes as follows...
0) connect to server 0) connect to server
1) request challenge 1) request challenge
@ -210,7 +209,7 @@ void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr,
*/ */
// 0) Connect to the server // 0) Connect to the server
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
if(sock < 0) { if (sock < 0) {
hydra_report(stderr, "Error: Child with pid %d terminating, can not connect\n", (int32_t)getpid()); hydra_report(stderr, "Error: Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -220,140 +219,165 @@ void service_radmin2(char *ip, int32_t sp, unsigned char options, char *miscptr,
challenge_request(msg); challenge_request(msg);
request = message2buffer(msg); request = message2buffer(msg);
hydra_send(sock, request, 10, 0); hydra_send(sock, request, 10, 0);
free(msg); free(msg);
free(request); free(request);
//2) receive response (working) // 2) receive response (working)
index = 0; index = 0;
while(index < 42) { //We're always expecting back a 42 byte buffer from a challenge request. while (index < 42) { // We're always expecting back a 42 byte buffer from a
switch(hydra_data_ready(sock)) { // challenge request.
case -1: switch (hydra_data_ready(sock)) {
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno)); case -1:
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno));
hydra_child_exit(1);
break;
case 0:
// keep waiting...
break;
default:
bytecount = hydra_recv(sock, buffer + index, 42 - index);
if (bytecount < 0) {
hydra_report(stderr,
"Error: Child with pid %d terminating, receive "
"error\nerror:\t%s\n",
(int32_t)getpid(), strerror(errno));
hydra_child_exit(1); hydra_child_exit(1);
break; }
case 0: index += bytecount;
//keep waiting...
break;
default:
bytecount = hydra_recv(sock, buffer+index, 42 - index);
if(bytecount < 0) {
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno));
hydra_child_exit(1);
}
index += bytecount;
} }
} }
//3) Send challenge solution. // 3) Send challenge solution.
// Get a password to work with. // Get a password to work with.
memset(password, 0x00, sizeof(password)); memset(password, 0x00, sizeof(password));
memset(encrypted, 0x00, sizeof(encrypted)); memset(encrypted, 0x00, sizeof(encrypted));
hydra_get_next_pair(); hydra_get_next_pair();
strncpy(password, hydra_get_next_password(), sizeof(password)-1); strncpy(password, hydra_get_next_password(), sizeof(password) - 1);
//MD5 the password to generate the password key, this is used with twofish below. // MD5 the password to generate the password key, this is used with twofish
// below.
err = gcry_md_open(&md, GCRY_MD_MD5, 0); err = gcry_md_open(&md, GCRY_MD_MD5, 0);
if(err) { if (err) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_md_open error (%08x)\n%s/%s", (int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err)); hydra_report(stderr,
"Error: Child with pid %d terminating, gcry_md_open error "
"(%08x)\n%s/%s",
(int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err));
hydra_child_exit(1); hydra_child_exit(1);
} }
gcry_md_reset(md); gcry_md_reset(md);
gcry_md_write(md, password, 100); gcry_md_write(md, password, 100);
if(gcry_md_read(md, 0) == NULL) { if (gcry_md_read(md, 0) == NULL) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_md_read error (%08x)\n", (int32_t)getpid(), index); hydra_report(stderr, "Error: Child with pid %d terminating, gcry_md_read error (%08x)\n", (int32_t)getpid(), index);
hydra_child_exit(1); hydra_child_exit(1);
} }
memcpy(rawkey, gcry_md_read(md, 0), 16); memcpy(rawkey, gcry_md_read(md, 0), 16);
gcry_md_close(md); gcry_md_close(md);
//3.a) generate a new message from the buffer // 3.a) generate a new message from the buffer
msg = buffer2message(buffer); msg = buffer2message(buffer);
//3.b) encrypt data received using pkey & known IV // 3.b) encrypt data received using pkey & known IV
err= gcry_cipher_open(&cipher, GCRY_CIPHER_TWOFISH128, GCRY_CIPHER_MODE_CBC, 0); err = gcry_cipher_open(&cipher, GCRY_CIPHER_TWOFISH128, GCRY_CIPHER_MODE_CBC, 0);
if(err) { if (err) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_cipher_open error (%08x)\n%s/%s", (int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err)); hydra_report(stderr,
"Error: Child with pid %d terminating, gcry_cipher_open "
"error (%08x)\n%s/%s",
(int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err));
hydra_child_exit(1); hydra_child_exit(1);
} }
err = gcry_cipher_setiv(cipher, IV, 16); err = gcry_cipher_setiv(cipher, IV, 16);
if(err) { if (err) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_cipher_setiv error (%08x)\n%s/%s", (int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err)); hydra_report(stderr,
"Error: Child with pid %d terminating, gcry_cipher_setiv "
"error (%08x)\n%s/%s",
(int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err));
hydra_child_exit(1); hydra_child_exit(1);
} }
err = gcry_cipher_setkey(cipher, rawkey, 16); err = gcry_cipher_setkey(cipher, rawkey, 16);
if(err) { if (err) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_cipher_setkey error (%08x)\n%s/%s", (int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err)); hydra_report(stderr,
"Error: Child with pid %d terminating, gcry_cipher_setkey "
"error (%08x)\n%s/%s",
(int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err));
hydra_child_exit(1); hydra_child_exit(1);
} }
err = gcry_cipher_encrypt(cipher, encrypted, 32, msg->data, 32); err = gcry_cipher_encrypt(cipher, encrypted, 32, msg->data, 32);
if(err) { if (err) {
hydra_report(stderr, "Error: Child with pid %d terminating, gcry_cipher_encrypt error (%08x)\n%s/%s", (int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err)); hydra_report(stderr,
"Error: Child with pid %d terminating, gcry_cipher_encrypt "
"error (%08x)\n%s/%s",
(int32_t)getpid(), index, gcry_strsource(err), gcry_strerror(err));
hydra_child_exit(1); hydra_child_exit(1);
} }
gcry_cipher_close(cipher); gcry_cipher_close(cipher);
//3.c) half sum - this is the solution to the challenge. // 3.c) half sum - this is the solution to the challenge.
for(index=0; index < 16; index++) { for (index = 0; index < 16; index++) {
*(encrypted+index) += *(encrypted+index+16); *(encrypted + index) += *(encrypted + index + 16);
} }
memset((encrypted+16), 0x00, 16); memset((encrypted + 16), 0x00, 16);
//3.d) send half sum // 3.d) send half sum
challenge_response(msg, encrypted); challenge_response(msg, encrypted);
request = message2buffer(msg); request = message2buffer(msg);
hydra_send(sock, request, 42, 0); hydra_send(sock, request, 42, 0);
free(msg); free(msg);
free(request); free(request);
//4) receive auth success/failure // 4) receive auth success/failure
index = 0; index = 0;
while(index < 10) { //We're always expecting back a 42 byte buffer from a challenge request. while (index < 10) { // We're always expecting back a 42 byte buffer from a
switch(hydra_data_ready(sock)) { // challenge request.
case -1: switch (hydra_data_ready(sock)) {
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno)); case -1:
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno));
hydra_child_exit(1);
break;
case 0:
// keep waiting...
break;
default:
bytecount = hydra_recv(sock, buffer + index, 10 - index);
if (bytecount < 0) {
hydra_report(stderr,
"Error: Child with pid %d terminating, receive "
"error\nerror:\t%s\n",
(int32_t)getpid(), strerror(errno));
hydra_child_exit(1); hydra_child_exit(1);
break; }
case 0: index += bytecount;
//keep waiting...
break;
default:
bytecount = hydra_recv(sock, buffer+index, 10 - index);
if(bytecount < 0) {
hydra_report(stderr, "Error: Child with pid %d terminating, receive error\nerror:\t%s\n", (int32_t)getpid(), strerror(errno));
hydra_child_exit(1);
}
index += bytecount;
} }
} }
msg = buffer2message(buffer); msg = buffer2message(buffer);
switch(msg->type) { switch (msg->type) {
case 0x0a: case 0x0a:
hydra_completed_pair_found(); hydra_completed_pair_found();
break; break;
case 0x0b: case 0x0b:
hydra_completed_pair(); hydra_completed_pair();
hydra_disconnect(sock); hydra_disconnect(sock);
break; break;
default: default:
hydra_report(stderr, "Error: Child with pid %d terminating, protocol error\n", (int32_t)getpid()); hydra_report(stderr, "Error: Child with pid %d terminating, protocol error\n", (int32_t)getpid());
hydra_child_exit(2); hydra_child_exit(2);
} }
free(msg);
} }
#endif #endif
} }
int32_t service_radmin2_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_radmin2_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_redis(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_redis(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *pass, buffer[510]; char *pass, buffer[510];
char *empty = ""; char *empty = "";
@ -15,7 +15,7 @@ int32_t start_redis(int32_t s, char *ip, int32_t port, unsigned char options, ch
snprintf(pass_num, 50, "%d", pass_len); snprintf(pass_num, 50, "%d", pass_len);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "*2\r\n$4\r\nAUTH\r\n$%.250s\r\n%.250s\r\n", pass_num, pass); sprintf(buffer, "*2\r\n$4\r\nAUTH\r\n$%.50s\r\n%.250s\r\n", pass_num, pass);
if (debug) if (debug)
hydra_report(stderr, "[DEBUG] Auth:\n %s\n", buffer); hydra_report(stderr, "[DEBUG] Auth:\n %s\n", buffer);
@ -24,6 +24,11 @@ int32_t start_redis(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
buf = hydra_receive_line(s); buf = hydra_receive_line(s);
if (buf == NULL) {
hydra_report(stderr, "[ERROR] Failed to receive response from Redis server.\n");
return 3;
}
if (buf[0] == '+') { if (buf[0] == '+') {
hydra_report_found_host(port, ip, "redis", fp); hydra_report_found_host(port, ip, "redis", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
@ -51,7 +56,7 @@ int32_t start_redis(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_redis_core(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname, int32_t tls) { void service_redis_core(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname, int32_t tls) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_REDIS, mysslport = PORT_REDIS_SSL; int32_t myport = PORT_REDIS, mysslport = PORT_REDIS_SSL;
@ -61,7 +66,7 @@ void service_redis_core(char *ip, int32_t sp, unsigned char options, char *miscp
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -77,24 +82,25 @@ void service_redis_core(char *ip, int32_t sp, unsigned char options, char *miscp
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
usleepn(250); usleepn(250);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_redis(sock, ip, port, options, miscptr, fp); next_run = start_redis(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* error exit */ case 3: /* error exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
break; break;
case 4: /* clean exit */ case 4: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
break;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
@ -103,32 +109,32 @@ void service_redis_core(char *ip, int32_t sp, unsigned char options, char *miscp
} }
} }
void service_redis(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_redis(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) { service_redis_core(ip, sp, options, miscptr, fp, port, hostname, 0); }
service_redis_core(ip, sp, options, miscptr, fp, port, hostname, 0);
}
/* /*
* Initial password authentication test and response test for the redis server, * Initial password authentication test and response test for the redis server,
* added by Petar Kaleychev <petar.kaleychev@gmail.com> * added by Petar Kaleychev <petar.kaleychev@gmail.com>
* The service_redis_init function is generating ping request as redis-cli (command line interface). * The service_redis_init function is generating ping request as redis-cli
* You can use redis-cli to connect with Redis. After start of the redis-server in another terminal the following: * (command line interface). You can use redis-cli to connect with Redis. After
* % ./redis-cli * start of the redis-server in another terminal the following: % ./redis-cli
* redis> ping * redis> ping
* when the server does not require password, leads to: * when the server does not require password, leads to:
* PONG * PONG
* when the server requires password, leads to: * when the server requires password, leads to:
* (error) NOAUTH Authentication required. * (error) NOAUTH Authentication required.
* or * or
* (error) ERR operation not permitted (for older redis versions) * (error) ERR operation not permitted (for older redis versions)
* That is used for initial password authentication and redis server response tests in service_redis_init * That is used for initial password authentication and redis server response
*/ * tests in service_redis_init
int32_t service_redis_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { */
int32_t service_redis_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// return codes: // return codes:
// 0 - when the server is redis and it requires password // 0 - when the server is redis and it requires password
// 1 - when the server is not redis or when the server does not require password // n - when the server is not redis or when the server does not require
// password
int32_t sock = -1; int32_t sock = -1;
int32_t myport = PORT_REDIS, mysslport = PORT_REDIS_SSL; int32_t myport = PORT_REDIS, mysslport = PORT_REDIS_SSL;
@ -147,35 +153,36 @@ int32_t service_redis_init(char *ip, int32_t sp, unsigned char options, char *mi
port = mysslport; port = mysslport;
} }
if (verbose) if (verbose)
printf("[VERBOSE] Initial redis password authentication test and response test ...\n"); printf("[VERBOSE] Initial redis password authentication test and response "
"test ...\n");
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Can not connect to port %d on the target\n", myport); hydra_report(stderr, "[ERROR] Can not connect to port %d on the target\n", myport);
hydra_child_exit(1); return 3;
} }
// generating ping request as redis-cli // generating ping request as redis-cli
if (debug) if (debug)
printf("[DEBUG] buffer = %s\n", buffer); printf("[DEBUG] buffer = %s\n", buffer);
// [debug mode]: buffer is: // [debug mode]: buffer is:
// *1 // *1
// $4 // $4
// ping // ping
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) { if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
return 1; return 2;
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (debug) if (debug)
printf("[DEBUG] buf = %s\n", buf); printf("[DEBUG] buf = %s\n", buf);
// authentication test // authentication test
if (strstr(buf, "+PONG") != NULL) { // the server does not require password if (strstr(buf, "+PONG") != NULL) { // the server does not require password
hydra_report(stderr, "[!] The server does not require password.\n"); hydra_report(stderr, "[!] The server %s does not require password.\n", hostname);
free(buf); free(buf);
return 1; return 2;
} }
// server response test // server response test
if (strstr(buf, "-NOAUTH Authentication required") == NULL && strstr(buf, "-ERR operation not permitted") == NULL) { if (strstr(buf, "-NOAUTH Authentication required") == NULL && strstr(buf, "-ERR operation not permitted") == NULL) {
hydra_report(stderr, "[ERROR] The server is not redis, exit.\n"); hydra_report(stderr, "[ERROR] The server is not redis, exit.\n");
free(buf); free(buf);
return 1; return 2;
} }
if (verbose) if (verbose)
printf("[VERBOSE] The redis server requires password.\n"); printf("[VERBOSE] The redis server requires password.\n");

View file

@ -5,9 +5,8 @@
#define COMMAND "/bin/ls /" #define COMMAND "/bin/ls /"
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
int32_t start_rexec(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_rexec(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[300] = "", buffer2[100], *bptr = buffer2; char *login, *pass, buffer[300] = "", buffer2[100], *bptr = buffer2;
int32_t ret; int32_t ret;
@ -45,7 +44,7 @@ int32_t start_rexec(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_rexec(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_rexec(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_REXEC, mysslport = PORT_REXEC_SSL; int32_t myport = PORT_REXEC, mysslport = PORT_REXEC_SSL;
@ -55,33 +54,33 @@ void service_rexec(char *ip, int32_t sp, unsigned char options, char *miscptr, F
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_rexec(sock, ip, port, options, miscptr, fp); next_run = start_rexec(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -89,19 +88,18 @@ void service_rexec(char *ip, int32_t sp, unsigned char options, char *miscptr, F
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0); hydra_child_exit(0);
} }
run = next_run; run = next_run;
} }
} }
int32_t service_rexec_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_rexec_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -8,13 +8,11 @@ client have to use port from 512 -> 1023 or server is denying the connection
no memleaks found on 110425 no memleaks found on 110425
*/ */
#define TERM "vt100/9600" #define TERM "vt100/9600"
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
int32_t start_rlogin(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_rlogin(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[300] = "", buffer2[100], *bptr = buffer2; char *login, *pass, buffer[300] = "", buffer2[100], *bptr = buffer2;
int32_t ret; int32_t ret;
@ -79,7 +77,8 @@ int32_t start_rlogin(int32_t s, char *ip, int32_t port, unsigned char options, c
hydra_completed_pair(); hydra_completed_pair();
} }
} else { } else {
/* if password is asked a second time, it means the pass we provided is wrong */ /* if password is asked a second time, it means the pass we provided is
* wrong */
hydra_completed_pair(); hydra_completed_pair();
} }
@ -88,7 +87,7 @@ int32_t start_rlogin(int32_t s, char *ip, int32_t port, unsigned char options, c
return 1; return 1;
} }
void service_rlogin(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_rlogin(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_RLOGIN, mysslport = PORT_RLOGIN_SSL; int32_t myport = PORT_RLOGIN, mysslport = PORT_RLOGIN_SSL;
@ -99,35 +98,35 @@ void service_rlogin(char *ip, int32_t sp, unsigned char options, char *miscptr,
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
/* 512 -> 1023 */ /* 512 -> 1023 */
hydra_set_srcport(1023); hydra_set_srcport(1023);
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_rlogin(sock, ip, port, options, miscptr, fp); next_run = start_rlogin(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -140,13 +139,13 @@ void service_rlogin(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
} }
int32_t service_rlogin_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_rlogin_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -6,7 +6,7 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_rpcap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_rpcap(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[1024]; char *login, *pass, buffer[1024];
@ -21,7 +21,8 @@ int32_t start_rpcap(int32_t s, char *ip, int32_t port, unsigned char options, ch
char bfr4[] = " "; char bfr4[] = " ";
bfr4[0] = strlen(login) + strlen(pass) + 8; bfr4[0] = strlen(login) + strlen(pass) + 8;
char bfr5[] = "\x00"; char bfr5[] = "\x00";
char bfr6[] = "\x01"; // x01 - when a password is required, x00 - when no need of password char bfr6[] = "\x01"; // x01 - when a password is required, x00 - when no need
// of password
char bfr7[] = "\x00\x00\x00"; char bfr7[] = "\x00\x00\x00";
char bfr8[] = " "; char bfr8[] = " ";
bfr8[0] = strlen(login); bfr8[0] = strlen(login);
@ -57,13 +58,12 @@ int32_t start_rpcap(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 3; return 3;
return 1; return 1;
} }
/* /*
if (strstr(buf, "Logon failure") == NULL) { if (strstr(buf, "Logon failure") == NULL) {
hydra_report(stderr, "[ERROR] rpcap error or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] rpcap error or service shutdown: %s\n",
free(buf); buf); free(buf); return 4;
return 4; }
} */
*/
free(buf); free(buf);
hydra_completed_pair(); hydra_completed_pair();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
@ -72,7 +72,7 @@ int32_t start_rpcap(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 2; return 2;
} }
void service_rpcap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_rpcap(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_RPCAP, mysslport = PORT_RPCAP_SSL; int32_t myport = PORT_RPCAP, mysslport = PORT_RPCAP_SSL;
@ -81,10 +81,10 @@ void service_rpcap(char *ip, int32_t sp, unsigned char options, char *miscptr, F
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
//usleep(300000); // usleep(300000);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -99,18 +99,19 @@ void service_rpcap(char *ip, int32_t sp, unsigned char options, char *miscptr, F
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_rpcap(sock, ip, port, options, miscptr, fp); next_run = start_rpcap(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
break;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
@ -119,7 +120,7 @@ void service_rpcap(char *ip, int32_t sp, unsigned char options, char *miscptr, F
} }
} }
int32_t service_rpcap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_rpcap_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, performed once only. // called before the childrens are forked off, performed once only.
// return codes: // return codes:
// 0 - rpcap with authentication // 0 - rpcap with authentication
@ -153,7 +154,7 @@ int32_t service_rpcap_init(char *ip, int32_t sp, unsigned char options, char *mi
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (strstr(buf, "NULL autentication not permitted") == NULL) { if (strstr(buf, "NULL authentication not permitted") == NULL) {
hydra_report(stderr, "[!] rpcap error or no need of authentication!\n"); hydra_report(stderr, "[!] rpcap error or no need of authentication!\n");
free(buf); free(buf);
return 1; return 1;

View file

@ -11,9 +11,8 @@ no memleaks found on 110425
*/ */
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
int32_t start_rsh(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_rsh(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, buffer[300] = "", buffer2[100], *bptr = buffer2; char *login, buffer[300] = "", buffer2[100], *bptr = buffer2;
int32_t ret; int32_t ret;
@ -40,8 +39,8 @@ int32_t start_rsh(int32_t s, char *ip, int32_t port, unsigned char options, char
if ((ret = hydra_recv(s, buffer, sizeof(buffer) - 1)) > 0) if ((ret = hydra_recv(s, buffer, sizeof(buffer) - 1)) > 0)
buffer[ret] = 0; buffer[ret] = 0;
else /* 0x00 is sent but hydra_recv transformed it */ else /* 0x00 is sent but hydra_recv transformed it */
if ((ret = hydra_recv(s, buffer, sizeof(buffer) - 1)) > 0) if ((ret = hydra_recv(s, buffer, sizeof(buffer) - 1)) > 0)
buffer[ret] = 0; buffer[ret] = 0;
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if (ret > 0 && (!hydra_string_match(buffer, "\\s(failure|incorrect|denied)"))) { if (ret > 0 && (!hydra_string_match(buffer, "\\s(failure|incorrect|denied)"))) {
#else #else
@ -58,7 +57,7 @@ int32_t start_rsh(int32_t s, char *ip, int32_t port, unsigned char options, char
return 1; return 1;
} }
void service_rsh(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_rsh(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_RSH, mysslport = PORT_RSH_SSL; int32_t myport = PORT_RSH, mysslport = PORT_RSH_SSL;
@ -69,34 +68,34 @@ void service_rsh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
while (1) { while (1) {
next_run = 0; next_run = 0;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
{ {
hydra_set_srcport(1023); hydra_set_srcport(1023);
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(275); // usleepn(275);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_tcp(ip, myport); sock = hydra_connect_tcp(ip, myport);
port = myport; port = myport;
} else { } else {
if (port != 0) if (port != 0)
mysslport = port; mysslport = port;
sock = hydra_connect_ssl(ip, mysslport, hostname); sock = hydra_connect_ssl(ip, mysslport, hostname);
port = mysslport; port = mysslport;
}
if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
} }
case 2: /* run the cracking function */ if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1);
}
next_run = 2;
break;
}
case 2: /* run the cracking function */
next_run = start_rsh(sock, ip, port, options, miscptr, fp); next_run = start_rsh(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -109,13 +108,13 @@ void service_rsh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
} }
int32_t service_rsh_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_rsh_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -6,19 +6,21 @@
// //
// //
#include <stdio.h> #ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "hydra-mod.h" #include "hydra-mod.h"
#include <string.h>
#include "sasl.h" #include "sasl.h"
#include <stdio.h>
#include <string.h>
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
char packet[500]; char packet[500];
char packet2[500]; char packet2[500];
int32_t is_Unauthorized(char *s) { int32_t is_Unauthorized(char *s) {
if (strcasestr(s, "401 Unauthorized") != NULL) {
if (strstr(s, "401 Unauthorized") != NULL) {
return 1; return 1;
} else { } else {
return 0; return 0;
@ -26,8 +28,7 @@ int32_t is_Unauthorized(char *s) {
} }
int32_t is_NotFound(char *s) { int32_t is_NotFound(char *s) {
if (strcasestr(s, "404 Stream") != NULL || strcasestr(s, "404 Not") != NULL) {
if (strstr(s, "404 Stream Not Found") != NULL) {
return 1; return 1;
} else { } else {
return 0; return 0;
@ -35,8 +36,7 @@ int32_t is_NotFound(char *s) {
} }
int32_t is_Authorized(char *s) { int32_t is_Authorized(char *s) {
if (strcasestr(s, "200 OK") != NULL) {
if (strstr(s, "200 OK") != NULL) {
return 1; return 1;
} else { } else {
return 0; return 0;
@ -44,8 +44,7 @@ int32_t is_Authorized(char *s) {
} }
int32_t use_Basic_Auth(char *s) { int32_t use_Basic_Auth(char *s) {
if (strcasestr(s, "WWW-Authenticate: Basic") != NULL) {
if (strstr(s, "WWW-Authenticate: Basic") != NULL) {
return 1; return 1;
} else { } else {
return 0; return 0;
@ -53,16 +52,13 @@ int32_t use_Basic_Auth(char *s) {
} }
int32_t use_Digest_Auth(char *s) { int32_t use_Digest_Auth(char *s) {
if (strcasestr(s, "WWW-Authenticate: Digest") != NULL) {
if (strstr(s, "WWW-Authenticate: Digest") != NULL) {
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} }
void create_core_packet(int32_t control, char *ip, int32_t port) { void create_core_packet(int32_t control, char *ip, int32_t port) {
char *target = hydra_address2string(ip); char *target = hydra_address2string(ip);
@ -76,12 +72,14 @@ void create_core_packet(int32_t control, char *ip, int32_t port) {
} }
} }
} }
int32_t start_rtsp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_rtsp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[500], buffer2[500]; char *login, *pass, buffer[1030], buffer2[500];
char *lresp; char *lresp;
memset(buffer, 0, sizeof(buffer));
memset(buffer2, 0, sizeof(buffer2));
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
if (strlen(pass = hydra_get_next_password()) == 0) if (strlen(pass = hydra_get_next_password()) == 0)
@ -95,57 +93,57 @@ int32_t start_rtsp(int32_t s, char *ip, int32_t port, unsigned char options, cha
lresp = hydra_receive_line(s); lresp = hydra_receive_line(s);
if (lresp == NULL) { if (lresp == NULL) {
fprintf(stderr, "[ERROR] no server reply"); hydra_report(stderr, "[ERROR] no server reply\n");
return 1; return 1;
} }
if (is_NotFound(lresp)) { if (is_NotFound(lresp)) {
printf("[INFO] Server does not need credentials\n"); free(lresp);
hydra_report(stderr, "[INFO] Server does not need credentials\n");
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) { if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
return 3; return 3;
} }
return 1; return 1;
} else { } else {
create_core_packet(1, ip, port); create_core_packet(1, ip, port);
if (use_Basic_Auth(lresp) == 1) {
sprintf(buffer2, "%.260s:%.260s", login, pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%sAuthorization: : Basic %s\r\n\r\n", packet2, buffer2);
if (debug) {
hydra_report(stderr, "C:%s\n", buffer);
}
}
if (use_Digest_Auth(lresp) == 1) { if (use_Digest_Auth(lresp) == 1) {
char *dbuf = NULL; char aux[500] = "", dbuf[500] = "", *result = NULL;
char aux[500] = "";
char *pbuffer = hydra_strcasestr(lresp, "WWW-Authenticate: Digest "); char *pbuffer = hydra_strcasestr(lresp, "WWW-Authenticate: Digest ");
strncpy(aux, pbuffer + strlen("WWW-Authenticate: Digest "), sizeof(buffer)); strncpy(aux, pbuffer + strlen("WWW-Authenticate: Digest "), sizeof(aux));
aux[sizeof(aux) - 1] = '\0'; aux[sizeof(aux) - 1] = '\0';
free(lresp);
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
sasl_digest_md5(dbuf, login, pass, aux, miscptr, "rtsp", hydra_address2string(ip), port, ""); result = sasl_digest_md5(dbuf, login, pass, aux, miscptr, "rtsp", hydra_address2string(ip), port, "");
#else #else
printf("[ERROR] Digest auth required but compiled without OpenSSL/MD5 support\n"); hydra_report(stderr, "[ERROR] Digest auth required but compiled "
"without OpenSSL/MD5 support\n");
return 3; return 3;
#endif #endif
if (result == NULL) {
if (dbuf == NULL) { hydra_report(stderr, "[ERROR] digest generation failed\n");
fprintf(stderr, "[ERROR] digest generation failed\n");
return 3; return 3;
} }
sprintf(buffer, "%sAuthorization: Digest %s\r\n\r\n", packet2, dbuf); sprintf(buffer, "%.500sAuthorization: Digest %.500s\r\n\r\n", packet2, dbuf);
if (debug)
if (debug) {
hydra_report(stderr, "C:%s\n", buffer); hydra_report(stderr, "C:%s\n", buffer);
} } else if (use_Basic_Auth(lresp) == 1) {
free(lresp);
sprintf(buffer2, "%.249s:%.249s", login, pass);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.500sAuthorization: : Basic %.500s\r\n\r\n", packet2, buffer2);
if (debug)
hydra_report(stderr, "C:%s\n", buffer);
} else {
hydra_report(stderr, "[ERROR] unknown authentication protocol\n");
return 1;
}
if (strlen(buffer) == 0) {
hydra_report(stderr, "[ERROR] could not identify HTTP authentication used\n");
return 1;
} }
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -153,33 +151,36 @@ int32_t start_rtsp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
lresp = NULL; lresp = NULL;
lresp = hydra_receive_line(s); lresp = hydra_receive_line(s);
if ((is_NotFound(lresp))) { if (lresp == NULL) {
hydra_report(stderr, "[ERROR] no server reply\n");
return 1;
}
if (is_NotFound(lresp) || is_Authorized(lresp)) {
free(lresp);
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) { if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
return 3; return 3;
} }
return 1; return 1;
} }
free(lresp);
hydra_completed_pair(); hydra_completed_pair();
} }
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
//not rechead // not rechead
return 2; return 2;
} }
void service_rtsp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_rtsp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_RTSP/*, mysslport = PORT_RTSP_SSL*/; int32_t myport = PORT_RTSP /*, mysslport = PORT_RTSP_SSL*/;
hydra_register_socket(sp); hydra_register_socket(sp);
@ -187,9 +188,8 @@ void service_rtsp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) { if (sock >= 0) {
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
} }
@ -202,16 +202,16 @@ void service_rtsp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_rtsp(sock, ip, port, options, miscptr, fp); next_run = start_rtsp(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) { if (sock >= 0) {
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
} }
@ -225,7 +225,7 @@ void service_rtsp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
int32_t service_rtsp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_rtsp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.

View file

@ -1,4 +1,5 @@
// submitted by Alexander Timorin <ATimorin@ptsecurity.com> and Sergey Gordeychik // submitted by Alexander Timorin <ATimorin@ptsecurity.com> and Sergey
// Gordeychik
#include "hydra-mod.h" #include "hydra-mod.h"
@ -6,16 +7,24 @@
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
unsigned char p_cotp[] = "\x03\x00\x00\x16\x11\xe0\x00\x00\x00\x17" "\x00\xc1\x02\x01\x00\xc2\x02\x01\x02\xc0" "\x01\x0a"; unsigned char p_cotp[] = "\x03\x00\x00\x16\x11\xe0\x00\x00\x00\x17"
"\x00\xc1\x02\x01\x00\xc2\x02\x01\x02\xc0"
"\x01\x0a";
unsigned char p_s7_negotiate_pdu[] = "\x03\x00\x00\x19\x02\xf0\x80\x32\x01\x00" "\x00\x02\x00\x00\x08\x00\x00\xf0\x00\x00" "\x01\x00\x01\x01\xe0"; unsigned char p_s7_negotiate_pdu[] = "\x03\x00\x00\x19\x02\xf0\x80\x32\x01\x00"
"\x00\x02\x00\x00\x08\x00\x00\xf0\x00\x00"
"\x01\x00\x01\x01\xe0";
unsigned char p_s7_read_szl[] = "\x03\x00\x00\x21\x02\xf0\x80\x32\x07\x00" "\x00\x03\x00\x00\x08\x00\x08\x00\x01\x12" "\x04\x11\x44\x01\x00\xff\x09\x00\x04\x01" "\x32\x00\x04"; unsigned char p_s7_read_szl[] = "\x03\x00\x00\x21\x02\xf0\x80\x32\x07\x00"
"\x00\x03\x00\x00\x08\x00\x08\x00\x01\x12"
"\x04\x11\x44\x01\x00\xff\x09\x00\x04\x01"
"\x32\x00\x04";
unsigned char p_s7_password_request[] = "\x03\x00\x00\x25\x02\xf0\x80\x32\x07\x00" "\x00\x00\x00\x00\x08\x00\x0c\x00\x01\x12" "\x04\x11\x45\x01\x00\xff\x09\x00\x08"; unsigned char p_s7_password_request[] = "\x03\x00\x00\x25\x02\xf0\x80\x32\x07\x00"
"\x00\x00\x00\x00\x08\x00\x0c\x00\x01\x12"
"\x04\x11\x45\x01\x00\xff\x09\x00\x08";
int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) {
char *empty = ""; char *empty = "";
char *pass, buffer[1024]; char *pass, buffer[1024];
char context[S7PASSLEN + 1]; char context[S7PASSLEN + 1];
@ -45,7 +54,7 @@ int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, c
} }
// send p_cotp and check first 2 bytes of answer // send p_cotp and check first 2 bytes of answer
if (hydra_send(s, (char *) p_cotp, 22, 0) < 0) if (hydra_send(s, (char *)p_cotp, 22, 0) < 0)
return 1; return 1;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
ret = hydra_recv_nb(s, buffer, sizeof(buffer)); ret = hydra_recv_nb(s, buffer, sizeof(buffer));
@ -57,7 +66,7 @@ int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, c
return 3; return 3;
// send p_s7_negotiate_pdu and check first 2 bytes of answer // send p_s7_negotiate_pdu and check first 2 bytes of answer
if (hydra_send(s, (char *) p_s7_negotiate_pdu, 25, 0) < 0) if (hydra_send(s, (char *)p_s7_negotiate_pdu, 25, 0) < 0)
return 1; return 1;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
ret = hydra_recv_nb(s, buffer, sizeof(buffer)); ret = hydra_recv_nb(s, buffer, sizeof(buffer));
@ -69,7 +78,7 @@ int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, c
return 3; return 3;
// send p_s7_read_szl and check first 2 bytes of answer // send p_s7_read_szl and check first 2 bytes of answer
if (hydra_send(s, (char *) p_s7_read_szl, 33, 0) < 0) if (hydra_send(s, (char *)p_s7_read_szl, 33, 0) < 0)
return 1; return 1;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
ret = hydra_recv_nb(s, buffer, sizeof(buffer)); ret = hydra_recv_nb(s, buffer, sizeof(buffer));
@ -108,7 +117,7 @@ int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, c
} }
if (buffer[27] == '\xd6' && buffer[28] == '\x05') { if (buffer[27] == '\xd6' && buffer[28] == '\x05') {
//hydra_report_found_host(port, ip, "s7-300", fp); // hydra_report_found_host(port, ip, "s7-300", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
hydra_report(stderr, "[INFO] No password protection enabled\n"); hydra_report(stderr, "[INFO] No password protection enabled\n");
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
@ -124,7 +133,7 @@ int32_t start_s7_300(int32_t s, char *ip, int32_t port, unsigned char options, c
return 1; return 1;
} }
void service_s7_300(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_s7_300(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t s7port = PORT_S7_300; int32_t s7port = PORT_S7_300;
@ -136,21 +145,21 @@ void service_s7_300(char *ip, int32_t sp, unsigned char options, char *miscptr,
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
sock = hydra_connect_tcp(ip, s7port); sock = hydra_connect_tcp(ip, s7port);
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = start_s7_300(sock, ip, s7port, options, miscptr, fp); next_run = start_s7_300(sock, ip, s7port, options, miscptr, fp);
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
break; break;
case 2: /* clean exit */ case 2: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -163,13 +172,13 @@ void service_s7_300(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
} }
int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// 1 skip target without generating an error // 1 skip target without generating an error
@ -211,7 +220,7 @@ int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *m
} }
// send p_cotp and check first 2 bytes of answer // send p_cotp and check first 2 bytes of answer
if (hydra_send(sock, (char *) p_cotp, 22, 0) < 0) { if (hydra_send(sock, (char *)p_cotp, 22, 0) < 0) {
fprintf(stderr, "[ERROR] can not send data to service\n"); fprintf(stderr, "[ERROR] can not send data to service\n");
return 3; return 3;
} }
@ -226,7 +235,7 @@ int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *m
return 3; return 3;
} }
// send p_s7_negotiate_pdu and check first 2 bytes of answer // send p_s7_negotiate_pdu and check first 2 bytes of answer
if (hydra_send(sock, (char *) p_s7_negotiate_pdu, 25, 0) < 0) { if (hydra_send(sock, (char *)p_s7_negotiate_pdu, 25, 0) < 0) {
fprintf(stderr, "[ERROR] can not send data to service (2)\n"); fprintf(stderr, "[ERROR] can not send data to service (2)\n");
return 3; return 3;
} }
@ -241,7 +250,7 @@ int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *m
return 3; return 3;
} }
// send p_s7_read_szl and check first 2 bytes of answer // send p_s7_read_szl and check first 2 bytes of answer
if (hydra_send(sock, (char *) p_s7_read_szl, 33, 0) < 0) { if (hydra_send(sock, (char *)p_s7_read_szl, 33, 0) < 0) {
fprintf(stderr, "[ERROR] can not send data to service (3)\n"); fprintf(stderr, "[ERROR] can not send data to service (3)\n");
return 3; return 3;
} }
@ -276,7 +285,8 @@ int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *m
// 0xd602 - wrong password // 0xd602 - wrong password
if (ret > 30) { if (ret > 30) {
if ((buffer[27] == '\x00' && buffer[28] == '\x00') || (buffer[27] == '\xd6' && buffer[28] == '\x05')) { if ((buffer[27] == '\x00' && buffer[28] == '\x00') || (buffer[27] == '\xd6' && buffer[28] == '\x05')) {
hydra_report(stderr, "[INFO] No password protection enabled, no password tests are necessary!\n"); hydra_report(stderr, "[INFO] No password protection enabled, no password "
"tests are necessary!\n");
return 1; return 1;
} }
} }
@ -286,6 +296,7 @@ int32_t service_s7_300_init(char *ip, int32_t sp, unsigned char options, char *m
return 0; return 0;
} }
void usage_s7_300(const char* service) { void usage_s7_300(const char *service) {
printf("Module S7-300 is for a special Siemens PLC. It either requires only a password or no authentication, so just use the -p or -P option.\n\n"); printf("Module S7-300 is for a special Siemens PLC. It either requires only a "
"password or no authentication, so just use the -p or -P option.\n\n");
} }

View file

@ -1,25 +1,24 @@
#include "hydra-mod.h" #include "hydra-mod.h"
// checked for memleaks on 110425, none found // checked for memleaks on 110425, none found
#ifndef LIBSAPR3 #ifndef LIBSAPR3
void dummy_sapr3() { void dummy_sapr3() { printf("\n"); }
printf("\n");
}
#else #else
#include <saprfc.h>
#include <ctype.h> #include <ctype.h>
#include <saprfc.h>
/* temporary workaround fix */ /* temporary workaround fix */
const int32_t *__ctype_tolower; const int32_t *__ctype_tolower;
const int32_t *__ctype_toupper; const int32_t *__ctype_toupper;
const int32_t *__ctype_b; const int32_t *__ctype_b;
extern void flood(); /* for -lm */ extern void flood(); /* for -lm */
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
RFC_ERROR_INFO_EX error_info; RFC_ERROR_INFO_EX error_info;
int32_t start_sapr3(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_sapr3(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
RFC_HANDLE handle; RFC_HANDLE handle;
char *empty = ""; char *empty = "";
char *login, *pass, buffer[1024]; char *login, *pass, buffer[1024];
@ -28,7 +27,8 @@ int32_t start_sapr3(int32_t s, char *ip, int32_t port, unsigned char options, ch
int32_t sysnr = port % 100; int32_t sysnr = port % 100;
char opts[] = "RFCINI=N RFCTRACE=N BALANCE=N DEBUG=N TRACE=0 ABAP_DEBUG=0"; char opts[] = "RFCINI=N RFCTRACE=N BALANCE=N DEBUG=N TRACE=0 ABAP_DEBUG=0";
// char opts[] = "RFCINI=N RFCTRACE=Y BALANCE=N DEBUG=Y TRACE=Y ABAP_DEBUG=Y"; // char opts[] = "RFCINI=N RFCTRACE=Y BALANCE=N DEBUG=Y TRACE=Y
// ABAP_DEBUG=Y";
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
login = empty; login = empty;
@ -37,36 +37,37 @@ int32_t start_sapr3(int32_t s, char *ip, int32_t port, unsigned char options, ch
if (strlen(login) > 0) if (strlen(login) > 0)
for (i = 0; i < strlen(login); i++) for (i = 0; i < strlen(login); i++)
login[i] = (char) toupper(login[i]); login[i] = (char)toupper(login[i]);
if (strlen(pass) > 0) if (strlen(pass) > 0)
for (i = 0; i < strlen(pass); i++) for (i = 0; i < strlen(pass); i++)
pass[i] = (char) toupper(pass[i]); pass[i] = (char)toupper(pass[i]);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
memset(&error_info, 0, sizeof(error_info)); memset(&error_info, 0, sizeof(error_info));
//strcpy(buf, "mvse001"); // strcpy(buf, "mvse001");
snprintf(buffer, sizeof(buffer), "ASHOST=%s SYSNR=%02d CLIENT=%03d USER=\"%s\" PASSWD=\"%s\" LANG=DE %s", hydra_address2string(ip), sysnr, atoi(miscptr), login, pass, opts); snprintf(buffer, sizeof(buffer), "ASHOST=%s SYSNR=%02d CLIENT=%03d USER=\"%s\" PASSWD=\"%s\" LANG=DE %s", hydra_address2string(ip), sysnr, atoi(miscptr), login, pass, opts);
/* /*
USER=SAPCPIC PASSWORD=admin USER=SAPCPIC PASSWORD=admin
USER=SAP* PASSWORD=PASS USER=SAP* PASSWORD=PASS
## do we need these options? ## do we need these options?
SAPSYS=3 SNC_MODE=N SAPGUI=N INVISIBLE=N GUIATOPEN=Y NRCALL=00001 CLOSE=N SAPSYS=3 SNC_MODE=N SAPGUI=N INVISIBLE=N GUIATOPEN=Y NRCALL=00001 CLOSE=N
ASHOST= // IP ASHOST= // IP
SYSNR= // port - 3200, scale 2 SYSNR= // port - 3200, scale 2
CLIENT= // miscptr, scale 2 CLIENT= // miscptr, scale 2
ABAP_DEBUG=0 ABAP_DEBUG=0
USER= USER=
PASSWD= PASSWD=
LANG=DE LANG=DE
*/ */
//printf ("DEBUG: %d Connectstring \"%s\"\n",sizeof(error_info),buffer); // printf ("DEBUG: %d Connectstring \"%s\"\n",sizeof(error_info),buffer);
handle = RfcOpenEx(buffer, &error_info); handle = RfcOpenEx(buffer, &error_info);
//printf("DEBUG: handle %d, key %s, message %s\n", handle, error_info.key, error_info.message); // printf("DEBUG: handle %d, key %s, message %s\n", handle, error_info.key,
// error_info.message);
if (handle <= RFC_HANDLE_NULL) if (handle <= RFC_HANDLE_NULL)
return 3; return 3;
@ -89,7 +90,7 @@ int32_t start_sapr3(int32_t s, char *ip, int32_t port, unsigned char options, ch
return 1; return 1;
} }
void service_sapr3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_sapr3(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
hydra_register_socket(sp); hydra_register_socket(sp);
@ -97,12 +98,14 @@ void service_sapr3(char *ip, int32_t sp, unsigned char options, char *miscptr, F
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
next_run = start_sapr3(sock, ip, port, options, miscptr, fp); next_run = start_sapr3(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 2: case 2:
hydra_child_exit(0); hydra_child_exit(0);
case 3: /* clean exit */ case 3: /* clean exit */
fprintf(stderr, "[ERROR] could not connect to target port %d\n", port); fprintf(stderr, "[ERROR] could not connect to target port %d\n", port);
hydra_child_exit(1); hydra_child_exit(1);
case 4: case 4:
@ -117,13 +120,13 @@ void service_sapr3(char *ip, int32_t sp, unsigned char options, char *miscptr, F
#endif #endif
int32_t service_sapr3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_sapr3_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -131,6 +134,4 @@ int32_t service_sapr3_init(char *ip, int32_t sp, unsigned char options, char *mi
return 0; return 0;
} }
void usage_sapr3(const char* service) { void usage_sapr3(const char *service) { printf("Module sapr3 requires the client id, a number between 0 and 99\n\n"); }
printf("Module sapr3 requires the client id, a number between 0 and 99\n\n");
}

View file

@ -1,4 +1,4 @@
/* simple sip digest auth (md5) module 2009/02/19 /* simple sip digest auth (md5) module 2009/02/19
* written by gh0st 2005 * written by gh0st 2005
* modified by Jean-Baptiste Aviat <jba [at] hsc [dot] `french tld`> - should * modified by Jean-Baptiste Aviat <jba [at] hsc [dot] `french tld`> - should
* work now, but only with -T 1 * work now, but only with -T 1
@ -10,13 +10,11 @@
#ifndef LIBOPENSSL #ifndef LIBOPENSSL
#include <stdio.h> #include <stdio.h>
void dummy_sip() { void dummy_sip() { printf("\n"); }
printf("\n");
}
#else #else
#include <stdint.h>
#include "sasl.h" #include "sasl.h"
#include <stdint.h>
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec); extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
@ -25,8 +23,7 @@ char *get_iface_ip(uint64_t ip);
int32_t cseq; int32_t cseq;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
#define SIP_MAX_BUF 1024
#define SIP_MAX_BUF 1024
void empty_register(char *buf, char *host, char *lhost, int32_t port, int32_t lport, char *user) { void empty_register(char *buf, char *host, char *lhost, int32_t port, int32_t lport, char *user) {
memset(buf, 0, SIP_MAX_BUF); memset(buf, 0, SIP_MAX_BUF);
@ -45,13 +42,13 @@ int32_t get_sip_code(char *buf) {
int32_t code; int32_t code;
char tmpbuf[SIP_MAX_BUF], word[SIP_MAX_BUF]; char tmpbuf[SIP_MAX_BUF], word[SIP_MAX_BUF];
if (sscanf(buf, "%s %i %s", tmpbuf, &code, word) != 3) if (sscanf(buf, "%256s %i %256s", tmpbuf, &code, word) != 3)
return -1; return -1;
return code; return code;
} }
int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, unsigned char options, char *miscptr, FILE * fp) { int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, unsigned char options, char *miscptr, FILE *fp) {
char *login, *pass, *host, buffer[SIP_MAX_BUF]; char *login, *pass, *host, buffer[SIP_MAX_BUF], *result = NULL;
int32_t i; int32_t i;
char buf[SIP_MAX_BUF]; char buf[SIP_MAX_BUF];
@ -81,7 +78,7 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
while (try < 2 && !has_sip_cred) { while (try < 2 && !has_sip_cred) {
try++; try++;
if (hydra_data_ready_timed(s, 3, 0) > 0) { if (hydra_data_ready_timed(s, 3, 0) > 0) {
i = hydra_recv(s, (char *) buf, sizeof(buf) - 1); i = hydra_recv(s, (char *)buf, sizeof(buf) - 1);
if (i > 0) if (i > 0)
buf[i] = '\0'; buf[i] = '\0';
if (strncmp(buf, "SIP/2.0 404", 11) == 0) { if (strncmp(buf, "SIP/2.0 404", 11) == 0) {
@ -94,17 +91,21 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
// if we already tried to connect, exit // if we already tried to connect, exit
if (external_ip_addr[0]) { if (external_ip_addr[0]) {
hydra_report(stdout, "[ERROR] Get error code 606 : session is not acceptable by the server\n"); hydra_report(stdout, "[ERROR] Get error code 606 : session is not "
"acceptable by the server\n");
return 2; return 2;
} }
if (verbose) if (verbose)
hydra_report(stdout, "[VERBOSE] Get error code 606 : session is not acceptable by the server,\n" hydra_report(stdout, "[VERBOSE] Get error code 606 : session is not "
"maybe it's an addressing issue as you are using NAT, trying to reconnect\n" "using addr from the server reply\n"); "acceptable by the server,\n"
/* "maybe it's an addressing issue as you are "
SIP/2.0 606 Not Acceptable "using NAT, trying to reconnect\n"
Via: SIP/2.0/UDP 192.168.0.21:46759;received=82.227.229.137 "using addr from the server reply\n");
*/ /*
SIP/2.0 606 Not Acceptable
Via: SIP/2.0/UDP 192.168.0.21:46759;received=82.227.229.137
*/
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if (hydra_string_match(buf, "Via: SIP.*received=")) { if (hydra_string_match(buf, "Via: SIP.*received=")) {
ptr = strstr(buf, "received="); ptr = strstr(buf, "received=");
@ -135,7 +136,9 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
hydra_report(stderr, "[INFO] S: %s\n", buf); hydra_report(stderr, "[INFO] S: %s\n", buf);
char buffer2[512]; char buffer2[512];
sasl_digest_md5(buffer2, login, pass, strstr(buf, "WWW-Authenticate: Digest") + strlen("WWW-Authenticate: Digest") + 1, host, "sip", NULL, 0, NULL); result = sasl_digest_md5(buffer2, login, pass, strstr(buf, "WWW-Authenticate: Digest") + strlen("WWW-Authenticate: Digest") + 1, host, "sip", NULL, 0, NULL);
if (result == NULL)
return 3;
memset(buffer, 0, SIP_MAX_BUF); memset(buffer, 0, SIP_MAX_BUF);
snprintf(buffer, SIP_MAX_BUF, snprintf(buffer, SIP_MAX_BUF,
@ -143,7 +146,11 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
"Via: SIP/2.0/UDP %s:%i\n" "Via: SIP/2.0/UDP %s:%i\n"
"From: <sip:%s@%s>\n" "From: <sip:%s@%s>\n"
"To: <sip:%s@%s>\n" "To: <sip:%s@%s>\n"
"Call-ID: 1337@%s\n" "CSeq: %i REGISTER\n" "Authorization: Digest %s\n" "Content-Length: 0\n\n", host, lip, lport, login, host, login, host, host, cseq, buffer2); "Call-ID: 1337@%s\n"
"CSeq: %i REGISTER\n"
"Authorization: Digest %s\n"
"Content-Length: 0\n\n",
host, lip, lport, login, host, login, host, host, cseq, buffer2);
cseq++; cseq++;
if (debug) if (debug)
@ -159,7 +166,7 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
try++; try++;
if (hydra_data_ready_timed(s, 5, 0) > 0) { if (hydra_data_ready_timed(s, 5, 0) > 0) {
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if ((i = hydra_recv(s, (char *) buf, sizeof(buf) - 1)) >= 0) if ((i = hydra_recv(s, (char *)buf, sizeof(buf) - 1)) >= 0)
buf[i] = 0; buf[i] = 0;
if (debug) if (debug)
hydra_report(stderr, "[INFO] S: %s\n", buf); hydra_report(stderr, "[INFO] S: %s\n", buf);
@ -182,17 +189,18 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
return 1; return 1;
} }
void service_sip(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_sip(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_SIP, mysslport = PORT_SIP_SSL; int32_t myport = PORT_SIP, mysslport = PORT_SIP_SSL;
char *lip = get_iface_ip((int32_t) *(&ip[1])); char *lip = get_iface_ip((int32_t) * (&ip[1]));
hydra_register_socket(sp); hydra_register_socket(sp);
// FIXME IPV6 // FIXME IPV6
if (ip[0] != 4) { if (ip[0] != 4) {
fprintf(stderr, "[ERROR] sip module is not ipv6 enabled yet, patches are appreciated.\n"); fprintf(stderr, "[ERROR] sip module is not ipv6 enabled yet, patches are "
"appreciated.\n");
hydra_child_exit(2); hydra_child_exit(2);
} }
@ -224,7 +232,7 @@ void service_sip(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
free(lip); free(lip);
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -263,7 +271,7 @@ char *get_iface_ip(uint64_t ip) {
tparamet.sin_port = htons(2000); tparamet.sin_port = htons(2000);
tparamet.sin_addr.s_addr = ip; tparamet.sin_addr.s_addr = ip;
if (connect(sfd, (const struct sockaddr *) &tparamet, sizeof(struct sockaddr_in))) { if (connect(sfd, (const struct sockaddr *)&tparamet, sizeof(struct sockaddr_in))) {
perror("connect"); perror("connect");
close(sfd); close(sfd);
return NULL; return NULL;
@ -271,7 +279,7 @@ char *get_iface_ip(uint64_t ip) {
struct sockaddr_in *local = malloc(sizeof(struct sockaddr_in)); struct sockaddr_in *local = malloc(sizeof(struct sockaddr_in));
int32_t size = sizeof(struct sockaddr_in); int32_t size = sizeof(struct sockaddr_in);
if (getsockname(sfd, (void *) local, (socklen_t *) & size)) { if (getsockname(sfd, (void *)local, (socklen_t *)&size)) {
perror("getsockname"); perror("getsockname");
close(sfd); close(sfd);
free(local); free(local);
@ -281,7 +289,7 @@ char *get_iface_ip(uint64_t ip) {
char buff[32]; char buff[32];
if (!inet_ntop(AF_INET, (void *) &local->sin_addr, buff, 32)) { if (!inet_ntop(AF_INET, (void *)&local->sin_addr, buff, 32)) {
perror("inet_ntop"); perror("inet_ntop");
free(local); free(local);
return NULL; return NULL;
@ -295,13 +303,13 @@ char *get_iface_ip(uint64_t ip) {
#endif #endif
int32_t service_sip_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_sip_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

File diff suppressed because it is too large Load diff

321
hydra-smb2.c Normal file
View file

@ -0,0 +1,321 @@
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2021 Karim Kanso, all rights reserved.
* kaz 'dot' kanso 'at' g mail 'dot' com
*/
#if defined(LIBSMBCLIENT)
#include "hydra-mod.h"
#include <errno.h>
#include <libsmbclient.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
typedef struct creds {
const char *workgroup;
const char *user;
const char *pass;
} creds_t;
const char default_workgroup[] = "WORKGROUP";
bool use_nt_hash = false;
const char *workgroup = default_workgroup;
const char *netbios_name = NULL;
#define EXIT_PROTOCOL_ERROR hydra_child_exit(2)
#define EXIT_CONNECTION_ERROR hydra_child_exit(1)
#define EXIT_NORMAL hydra_child_exit(0)
void smb2_auth_provider(SMBCCTX *c, const char *srv, const char *shr, char *wg, int wglen, char *un, int unlen, char *pw, int pwlen) {
creds_t *cr = (creds_t *)smbc_getOptionUserData(c);
strncpy(wg, cr->workgroup, wglen);
strncpy(un, cr->user, unlen);
strncpy(pw, cr->pass, pwlen);
wg[wglen - 1] = 0;
un[unlen - 1] = 0;
pw[pwlen - 1] = 0;
}
bool smb2_run_test(creds_t *cr, const char *server, uint16_t port) {
SMBCCTX *ctx = smbc_new_context();
if (ctx == NULL) {
hydra_report(stderr, "[ERROR] failed to create context\n");
EXIT_PROTOCOL_ERROR;
}
// samba internal debugging will be dumped to stderr
smbc_setDebug(ctx, debug ? 7 : 0);
smbc_setOptionDebugToStderr(ctx, true);
smbc_setFunctionAuthDataWithContext(ctx, smb2_auth_provider);
smbc_setOptionUserData(ctx, cr);
// 0 will use default port
smbc_setPort(ctx, port);
smbc_setOptionNoAutoAnonymousLogin(ctx, false);
smbc_setOptionUseNTHash(ctx, use_nt_hash);
if (netbios_name) {
smbc_setNetbiosName(ctx, (char *)netbios_name);
}
ctx = smbc_init_context(ctx);
if (!ctx) {
hydra_report(stderr, "[ERROR] smbc_init_context fail\n");
smbc_free_context(ctx, 1);
EXIT_PROTOCOL_ERROR;
}
char uri[2048];
snprintf(uri, sizeof(uri) - 1, "smb://%s/IPC$", server);
uri[sizeof(uri) - 1] = 0;
if (verbose) {
printf("[INFO] Connecting to: %s with %s\\%s%%%s\n", uri, cr->workgroup, cr->user, cr->pass);
}
SMBCFILE *fd = smbc_getFunctionOpendir(ctx)(ctx, uri);
if (fd) {
hydra_report(stderr, "[WARNING] Unexpected open on IPC$\n");
smbc_getFunctionClosedir(ctx)(ctx, fd);
smbc_free_context(ctx, 1);
fd = NULL;
return true;
}
/*
errno is set to 22 (EINVAL) when IPC$ as been opened but can not
be opened like a normal share. This corresponds to samba error
NT_STATUS_INVALID_INFO_CLASS, however this precise error code is
not available outside of the library. Thus, instead the library
sets a generic error (EINVAL) which can also correspond to other
cases (see below test).
This is not ideal, but appears to be the best that the
libsmbclient library offers as detailed state information is
internalised and not available. Further, it is also not possible
from the api to separate the connection, authentication and
authorisation.
The following text is taken from the libsmbclient header file for
the return value of the smbc_getFunctionOpendir function:
Valid directory handle. < 0 on error with errno set:
- EACCES Permission denied.
- EINVAL A NULL file/URL was passed, or the URL would
not parse, or was of incorrect form or smbc_init not
called.
- ENOENT durl does not exist, or name is an
- ENOMEM Insufficient memory to complete the
operation.
- ENOTDIR name is not a directory.
- EPERM the workgroup could not be found.
- ENODEV the workgroup or server could not be found.
*/
switch (errno) {
case 0:
// maybe false positive? unclear ... :( ... needs more testing
smbc_free_context(ctx, 1);
return true;
break;
case ENOENT:
// Noticed this when connecting to older samba servers on linux
// where any credentials are accepted.
hydra_report(stderr, "[WARNING] %s might accept any credential\n", server);
case EINVAL: // 22
// probably password ok, nominal case when connecting to a windows
// smb server with good credentials.
smbc_free_context(ctx, 1);
return true;
break;
case EPERM:
// Probably this means access denied inspite of mention above
// about being related to wrong workgroup. I have observed
// libsmbclient emitting this when connecting to a vanilla install
// of Windows 2019 server (non-domain) with wrong credentials. It
// appears related to a fallback null session being rejected after
// the library tries with provided credentials. If the null
// session is accepted, EACCES is returned.
case EACCES:
// 100% access denied
break;
case EHOSTUNREACH:
case ETIMEDOUT:
case ECONNREFUSED:
// there are probably more codes that could be added here to
// indicate connection errors.
hydra_report(stderr, "[ERROR] Error %s (%d) while connecting to %s\n", strerror(errno), errno, server);
smbc_free_context(ctx, 1);
EXIT_CONNECTION_ERROR;
break;
default:
// unexpected error
hydra_report(stderr, "[ERROR] %s (%d)\n", strerror(errno), errno);
smbc_free_context(ctx, 1);
EXIT_PROTOCOL_ERROR;
}
smbc_free_context(ctx, 1);
return false;
}
void service_smb2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
static int first_run = 0;
hydra_register_socket(sp);
while (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT))) {
char *login, *pass;
if (first_run && hydra_options.conwait)
sleep(hydra_options.conwait);
login = hydra_get_next_login();
pass = hydra_get_next_password();
creds_t cr = {
.user = login,
.pass = pass,
.workgroup = workgroup,
};
if (smb2_run_test(&cr, hydra_address2string(ip), port & 0xffff)) {
hydra_completed_pair_found();
} else {
hydra_completed_pair();
}
first_run = 1;
}
EXIT_NORMAL;
}
// constants used by option parser
const char tkn_workgroup[] = "workgroup:{";
const char tkn_nthash_true[] = "nthash:true";
const char tkn_nthash_false[] = "nthash:false";
const char tkn_netbios[] = "netbios:{";
#define CMP(s1, s2) (strncmp(s1, s2, sizeof(s1) - 1) == 0)
int32_t service_smb2_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
if (!miscptr)
return 0;
while (*miscptr) {
if (isspace(*miscptr)) {
miscptr++;
continue;
}
if (CMP(tkn_workgroup, miscptr)) {
if (workgroup != default_workgroup) {
// miscptr has already been processed, goto end
miscptr += strlen(miscptr) + 1;
continue;
}
miscptr += sizeof(tkn_workgroup) - 1;
char *p = strchr(miscptr, '}');
if (p == NULL) {
hydra_report(stderr, "[ERROR] missing closing brace in workgroup\n");
return -1;
}
*p = '\0';
workgroup = miscptr;
miscptr = p + 1;
if (verbose || debug) {
printf("[VERBOSE] Set workgroup to: %s\n", workgroup);
}
continue;
}
if (CMP(tkn_netbios, miscptr)) {
if (netbios_name != NULL) {
// miscptr has already been processed, goto end
miscptr += strlen(miscptr) + 1;
continue;
}
miscptr += sizeof(tkn_netbios) - 1;
char *p = strchr(miscptr, '}');
if (p == NULL) {
hydra_report(stderr, "[ERROR] missing closing brace in netbios name\n");
return -1;
}
*p = '\0';
netbios_name = miscptr;
miscptr = p + 1;
if (verbose || debug) {
printf("[VERBOSE] Set netbios name to: %s\n", netbios_name);
}
continue;
}
if (CMP(tkn_nthash_true, miscptr)) {
miscptr += sizeof(tkn_nthash_true) - 1;
use_nt_hash = true;
if (verbose || debug) {
printf("[VERBOSE] Enabled nthash.\n");
}
continue;
}
if (CMP(tkn_nthash_false, miscptr)) {
miscptr += sizeof(tkn_nthash_false) - 1;
use_nt_hash = false;
if (verbose || debug) {
printf("[VERBOSE] Disabled nthash.\n");
}
continue;
}
hydra_report(stderr, "[ERROR] unable to parse: %s\n", miscptr);
return -1;
}
return 0;
}
void usage_smb2(const char *service) {
puts("Module is a thin wrapper over the Samba client library (libsmbclient).\n"
"Thus, is capable of negotiating v1, v2 and v3 of the protocol.\n"
"\n"
"As this relies on Samba libraries, the system smb.conf will be parsed\n"
"when library starts up. It is possible to add configuration options\n"
"into that file that affect this module (such as min/max supported\n"
"protocol version).\n"
"\n"
"Caution: due to the high-level libsmbclient api (compared the smb\n"
"Hydra module), the accuracy is reduced. That is, this module works by\n"
"attempting to open the IPC$ share, which is reported as an error,\n"
"e.g. try this with the smbclient tool and it will raise the\n"
"NT_STATUS_INVALID_INFO_CLASS error). Sadly, the level of feedback\n"
"from the api does not distinguish this error from general/unknown\n"
"errors, so it might be possible to have false positives due to this\n"
"fact. One example of this is when the library can not parse the uri\n"
"correctly. On the other hand, false negatives could occur when a\n"
"valid credential is unable to open the share due to access control,\n"
"e.g. a locked/suspended account.\n"
"\n"
"There are three module options available:\n"
" workgroup:{XXX} - set the users workgroup\n"
" netbios:{XXX} - set the recipients netbios name\n"
" nthash:true or nthash:false - threat password as an nthash\n"
"\n"
"Examples: \n"
" hydra smb2://abc.com -l admin -p xxx -m workgroup:{OFFICE}\n"
" hydra smb2://1.2.3.4 -l admin -p F54F3A1D3C38140684FF4DAD029F25B5 -m "
"'workgroup:{OFFICE} nthash:true'\n"
" hydra -l admin -p F54F3A1D3C38140684FF4DAD029F25B5 "
"'smb2://1.2.3.4/workgroup:{OFFICE} nthash:true'\n");
}
#endif // LIBSMBCLIENT

View file

@ -24,7 +24,7 @@ int32_t tosent = 0;
int32_t smtp_enum_cmd = VRFY; int32_t smtp_enum_cmd = VRFY;
int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[500]; char *login, *pass, buffer[500];
@ -55,7 +55,7 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
return (1); return (1);
if (debug) if (debug)
hydra_report(stderr, "DEBUG S: %s", buf); hydra_report(stderr, "DEBUG S: %s", buf);
/* good return values are something like 25x */ /* good return values are something like 25x */
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if (hydra_string_match(buf, "^25\\d\\s")) { if (hydra_string_match(buf, "^25\\d\\s")) {
#else #else
@ -103,7 +103,7 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
return (1); return (1);
if (debug) if (debug)
hydra_report(stderr, "DEBUG S: %s", buf); hydra_report(stderr, "DEBUG S: %s", buf);
/* good return values are something like 25x */ /* good return values are something like 25x */
#ifdef HAVE_PCRE #ifdef HAVE_PCRE
if (hydra_string_match(buf, "^25\\d\\s")) { if (hydra_string_match(buf, "^25\\d\\s")) {
#else #else
@ -119,21 +119,25 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
err = strstr(buf, "Error"); err = strstr(buf, "Error");
if (err || tosent || strncmp(buf, "50", 2) == 0) { if (err || tosent || strncmp(buf, "50", 2) == 0) {
// we should report command not identified by the server // we should report command not identified by the server
//502 5.5.2 Error: command not recognized // 502 5.5.2 Error: command not recognized
//#ifdef HAVE_PCRE //#ifdef HAVE_PCRE
// if ((debug || hydra_string_match(buf, "\\scommand\\snot\\srecognized")) && err) { // if ((debug || hydra_string_match(buf,
//#else // "\\scommand\\snot\\srecognized")) && err) {
// if ((debug || strstr(buf, "command") != NULL) && err) { //#else
//#endif // if ((debug || strstr(buf, "command") != NULL) && err) {
// hydra_report(stderr, "Server %s", err); //#endif
// } // hydra_report(stderr, "Server %s", err);
if (strncmp(buf, "500 ", 4) == 0) { // }
hydra_report(stderr, "[ERROR] command is disabled on the server (choose different method): %s", buf); if (strncmp(buf, "500 ", 4) == 0 || strncmp(buf, "502 ", 4) == 0) {
hydra_report(stderr,
"[ERROR] command is disabled on the server (choose "
"different method): %s",
buf);
free(buf); free(buf);
return 3; return 4;
} }
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
//503 5.5.1 Error: nested MAIL command // 503 5.5.1 Error: nested MAIL command
strncpy(buffer, "RSET\r\n", sizeof(buffer)); strncpy(buffer, "RSET\r\n", sizeof(buffer));
free(buf); free(buf);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
@ -150,7 +154,7 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
return 2; return 2;
} }
void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1, i = 0; int32_t run = 1, next_run = 1, sock = -1, i = 0;
int32_t myport = PORT_SMTP, mysslport = PORT_SMTP_SSL; int32_t myport = PORT_SMTP, mysslport = PORT_SMTP_SSL;
char *buffer = "HELO hydra\r\n"; char *buffer = "HELO hydra\r\n";
@ -160,7 +164,7 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -175,7 +179,7 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
/* receive initial header */ /* receive initial header */
@ -185,17 +189,17 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
hydra_report(stderr, "Warning: SMTP does not allow connecting: %s\n", buf); hydra_report(stderr, "Warning: SMTP does not allow connecting: %s\n", buf);
hydra_child_exit(2); hydra_child_exit(2);
} }
// while (strstr(buf, "220 ") == NULL) { // while (strstr(buf, "220 ") == NULL) {
// free(buf); // free(buf);
// buf = hydra_receive_line(sock); // buf = hydra_receive_line(sock);
// } // }
// if (buf[0] != '2') { // if (buf[0] != '2') {
if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) { if (hydra_send(sock, buffer, strlen(buffer), 0) < 0) {
free(buf); free(buf);
hydra_child_exit(2); hydra_child_exit(2);
} }
// } // }
free(buf); free(buf);
if ((buf = hydra_receive_line(sock)) == NULL) if ((buf = hydra_receive_line(sock)) == NULL)
@ -207,7 +211,7 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
for (i = 0; i < strlen(miscptr); i++) for (i = 0; i < strlen(miscptr); i++)
miscptr[i] = (char) toupper((int32_t) miscptr[i]); miscptr[i] = (char)toupper((int32_t)miscptr[i]);
if (strncmp(miscptr, "EXPN", 4) == 0) if (strncmp(miscptr, "EXPN", 4) == 0)
smtp_enum_cmd = EXPN; smtp_enum_cmd = EXPN;
@ -216,8 +220,8 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
smtp_enum_cmd = RCPT; smtp_enum_cmd = RCPT;
} }
if (debug) { if (debug) {
hydra_report(stdout, "[VERBOSE] ");
switch (smtp_enum_cmd) { switch (smtp_enum_cmd) {
hydra_report(stdout, "[VERBOSE] ");
case VRFY: case VRFY:
hydra_report(stdout, "using SMTP VRFY command\n"); hydra_report(stdout, "using SMTP VRFY command\n");
break; break;
@ -232,15 +236,21 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
free(buf); free(buf);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_smtp_enum(sock, ip, port, options, miscptr, fp); next_run = start_smtp_enum(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) { if (sock >= 0) {
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
} }
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 4: /* unsupported exit */
if (sock >= 0) {
sock = hydra_disconnect(sock);
}
hydra_child_exit(3);
return;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0); hydra_child_exit(0);
@ -249,13 +259,13 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
} }
} }
int32_t service_smtp_enum_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_smtp_enum_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -263,9 +273,11 @@ int32_t service_smtp_enum_init(char *ip, int32_t sp, unsigned char options, char
return 0; return 0;
} }
void usage_smtp_enum(const char* service) { void usage_smtp_enum(const char *service) {
printf("Module smtp-enum is optionally taking one SMTP command of:\n\n" printf("Module smtp-enum is optionally taking one SMTP command of:\n\n"
"VRFY (default), EXPN, RCPT (which will connect using \"root\" account)\n" "VRFY (default), EXPN, RCPT (which will connect using \"root\" account)\n"
"login parameter is used as username and password parameter as the domain name\n" "login parameter is used as username and password parameter as the "
"For example to test if john@localhost exists on 192.168.0.1:\n" "hydra smtp-enum://192.168.0.1/vrfy -l john -p localhost\n\n"); "domain name\n"
"For example to test if john@localhost exists on 192.168.0.1:\n"
"hydra smtp-enum://192.168.0.1/vrfy -l john -p localhost\n\n");
} }

View file

@ -14,7 +14,7 @@ char *smtp_read_server_capacity(int32_t sock) {
free(buf); free(buf);
ptr = buf = hydra_receive_line(sock); ptr = buf = hydra_receive_line(sock);
if (buf != NULL) { if (buf != NULL) {
if (isdigit((int32_t) buf[0]) && buf[3] == ' ') if (isdigit((int32_t)buf[0]) && buf[3] == ' ')
resp = 1; resp = 1;
else { else {
if (buf[strlen(buf) - 1] == '\n') if (buf[strlen(buf) - 1] == '\n')
@ -27,7 +27,7 @@ char *smtp_read_server_capacity(int32_t sock) {
if ((ptr = strrchr(buf, '\n')) != NULL) { if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif #endif
ptr++; ptr++;
if (isdigit((int32_t) *ptr) && *(ptr + 3) == ' ') if (isdigit((int32_t)*ptr) && *(ptr + 3) == ' ')
resp = 1; resp = 1;
} }
} }
@ -36,8 +36,8 @@ char *smtp_read_server_capacity(int32_t sock) {
return buf; return buf;
} }
int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "", *result = NULL;
char *login, *pass, buffer[500], buffer2[500], *fooptr, *buf; char *login, *pass, buffer[500], buffer2[500], *fooptr, *buf;
if (strlen(login = hydra_get_next_login()) == 0) if (strlen(login = hydra_get_next_login()) == 0)
@ -52,7 +52,6 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
switch (smtp_auth_mechanism) { switch (smtp_auth_mechanism) {
case AUTH_PLAIN: case AUTH_PLAIN:
sprintf(buffer, "AUTH PLAIN\r\n"); sprintf(buffer, "AUTH PLAIN\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -62,13 +61,19 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 1; return 1;
if (strstr(buf, "334") == NULL) { if (strstr(buf, "334") == NULL) {
hydra_report(stderr, "[ERROR] SMTP PLAIN AUTH : %s\n", buf); hydra_report(stderr, "[ERROR] SMTP PLAIN AUTH : %s\n", buf);
if (strstr(buf, "503") != NULL) {
free(buf);
return 4;
}
free(buf); free(buf);
return 3; return 3;
} }
free(buf); free(buf);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
sasl_plain(buffer, login, pass); result = sasl_plain(buffer, login, pass);
if (result == NULL)
return 3;
char tmp_buffer[sizeof(buffer)]; char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer); sprintf(tmp_buffer, "%.250s\r\n", buffer);
@ -77,105 +82,104 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
break; break;
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
case AUTH_CRAMMD5:{ case AUTH_CRAMMD5: {
int32_t rc = 0; int32_t rc = 0;
char *preplogin; char *preplogin;
rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin); rc = sasl_saslprep(login, SASL_ALLOW_UNASSIGNED, &preplogin);
if (rc) { if (rc) {
return 3; return 3;
}
sprintf(buffer, "AUTH CRAM-MD5\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
}
//get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] SMTP CRAM-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 4);
free(buf);
memset(buffer2, 0, sizeof(buffer2));
sasl_cram_md5(buffer2, pass, buffer);
sprintf(buffer, "%s %.250s", preplogin, buffer2);
hydra_tobase64((unsigned char *) buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} }
break;
case AUTH_DIGESTMD5:{ sprintf(buffer, "AUTH CRAM-MD5\r\n");
sprintf(buffer, "AUTH DIGEST-MD5\r\n"); if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1;
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
//receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL) {
hydra_report(stderr, "[ERROR] SMTP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *) buffer, buf + 4);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2;
sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "smtp", NULL, 0, NULL);
if (fooptr == NULL)
return 3;
if (debug)
hydra_report(stderr, "DEBUG C: %s\n", buffer2);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} }
break; // get the one-time BASE64 encoded challenge
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] SMTP CRAM-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf + 4);
free(buf);
memset(buffer2, 0, sizeof(buffer2));
result = sasl_cram_md5(buffer2, pass, buffer);
if (result == NULL)
return 3;
sprintf(buffer, "%s %.250s", preplogin, buffer2);
hydra_tobase64((unsigned char *)buffer, strlen(buffer), sizeof(buffer));
char tmp_buffer[sizeof(buffer)];
sprintf(tmp_buffer, "%.250s\r\n", buffer);
strcpy(buffer, tmp_buffer);
free(preplogin);
} break;
case AUTH_DIGESTMD5: {
sprintf(buffer, "AUTH DIGEST-MD5\r\n");
if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1;
// receive
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL) {
hydra_report(stderr, "[ERROR] SMTP DIGEST-MD5 AUTH : %s\n", buf);
free(buf);
return 3;
}
memset(buffer, 0, sizeof(buffer));
from64tobits((char *)buffer, buf + 4);
free(buf);
if (debug)
hydra_report(stderr, "DEBUG S: %s\n", buffer);
fooptr = buffer2;
result = sasl_digest_md5(fooptr, login, pass, buffer, miscptr, "smtp", NULL, 0, NULL);
if (result == NULL)
return 3;
if (debug)
hydra_report(stderr, "DEBUG C: %s\n", buffer2);
hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%s\r\n", buffer2);
} break;
#endif #endif
case AUTH_NTLM:{ case AUTH_NTLM: {
unsigned char buf1[4096]; unsigned char buf1[4096];
unsigned char buf2[4096]; unsigned char buf2[4096];
//send auth and receive challenge // send auth and receive challenge
buildAuthRequest((tSmbNtlmAuthRequest *) buf2, 0, NULL, NULL); buildAuthRequest((tSmbNtlmAuthRequest *)buf2, 0, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *) buf2)); to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthRequest *)buf2));
sprintf(buffer, "AUTH NTLM %s\r\n", buf1); sprintf(buffer, "AUTH NTLM %s\r\n", buf1);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 1; return 1;
}
if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] SMTP NTLM AUTH : %s\n", buf);
free(buf);
return 3;
}
//recover challenge
from64tobits((char *) buf1, buf + 4);
free(buf);
buildAuthResponse((tSmbNtlmAuthChallenge *) buf1, (tSmbNtlmAuthResponse *) buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *) buf2));
sprintf(buffer, "%s\r\n", buf1);
} }
break; if ((buf = hydra_receive_line(s)) == NULL)
return 1;
if (strstr(buf, "334") == NULL || strlen(buf) < 8) {
hydra_report(stderr, "[ERROR] SMTP NTLM AUTH : %s\n", buf);
free(buf);
return 3;
}
// recover challenge
from64tobits((char *)buf1, buf + 4);
free(buf);
buildAuthResponse((tSmbNtlmAuthChallenge *)buf1, (tSmbNtlmAuthResponse *)buf2, 0, login, pass, NULL, NULL);
to64frombits(buf1, buf2, SmbLength((tSmbNtlmAuthResponse *)buf2));
sprintf(buffer, "%s\r\n", buf1);
} break;
default: default:
/* by default trying AUTH LOGIN */ /* by default trying AUTH LOGIN */
@ -188,13 +192,16 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
/* 504 5.7.4 Unrecognized authentication type */ /* 504 5.7.4 Unrecognized authentication type */
if (strstr(buf, "334") == NULL) { if (strstr(buf, "334") == NULL) {
hydra_report(stderr, "[ERROR] SMTP LOGIN AUTH, either this auth is disabled or server is not using auth: %s\n", buf); hydra_report(stderr,
"[ERROR] SMTP LOGIN AUTH, either this auth is disabled or "
"server is not using auth: %s\n",
buf);
free(buf); free(buf);
return 3; return 3;
} }
free(buf); free(buf);
sprintf(buffer2, "%.250s", login); sprintf(buffer2, "%.250s", login);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) { if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
@ -210,7 +217,7 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
free(buf); free(buf);
sprintf(buffer2, "%.250s", pass); sprintf(buffer2, "%.250s", pass);
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2)); hydra_tobase64((unsigned char *)buffer2, strlen(buffer2), sizeof(buffer2));
sprintf(buffer, "%.250s\r\n", buffer2); sprintf(buffer, "%.250s\r\n", buffer2);
} }
@ -224,7 +231,7 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
if (smtp_auth_mechanism == AUTH_DIGESTMD5) { if (smtp_auth_mechanism == AUTH_DIGESTMD5) {
if (strstr(buf, "334") != NULL && strlen(buf) >= 8) { if (strstr(buf, "334") != NULL && strlen(buf) >= 8) {
memset(buffer2, 0, sizeof(buffer2)); memset(buffer2, 0, sizeof(buffer2));
from64tobits((char *) buffer2, buf + 4); from64tobits((char *)buffer2, buf + 4);
if (strstr(buffer2, "rspauth=") != NULL) { if (strstr(buffer2, "rspauth=") != NULL) {
hydra_report_found_host(port, ip, "smtp", fp); hydra_report_found_host(port, ip, "smtp", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
@ -254,7 +261,7 @@ int32_t start_smtp(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 2; return 2;
} }
void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1, i = 0; int32_t run = 1, next_run = 1, sock = -1, i = 0;
int32_t myport = PORT_SMTP, mysslport = PORT_SMTP_SSL, disable_tls = 1; int32_t myport = PORT_SMTP, mysslport = PORT_SMTP_SSL, disable_tls = 1;
char *buf; char *buf;
@ -266,7 +273,7 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -282,7 +289,7 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -310,7 +317,7 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
for (i = 0; i < strlen(miscptr); i++) for (i = 0; i < strlen(miscptr); i++)
miscptr[i] = (char) toupper((int32_t) miscptr[i]); miscptr[i] = (char)toupper((int32_t)miscptr[i]);
if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) { if (strstr(miscptr, "TLS") || strstr(miscptr, "SSL") || strstr(miscptr, "STARTTLS")) {
disable_tls = 0; disable_tls = 0;
@ -325,7 +332,8 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf[0] != '2') { if (buf[0] != '2') {
hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer received from STARTTLS request\n"); hydra_report(stderr, "[ERROR] TLS negotiation failed, no answer "
"received from STARTTLS request\n");
} else { } else {
free(buf); free(buf);
if ((hydra_connect_to_ssl(sock, hostname) == -1)) { if ((hydra_connect_to_ssl(sock, hostname) == -1)) {
@ -346,9 +354,11 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
hydra_child_exit(2); hydra_child_exit(2);
} }
} else } else
hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is not supported by the server\n"); hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it "
"is not supported by the server\n");
} else } else
hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is not supported by the server\n"); hydra_report(stderr, "[ERROR] option to use TLS/SSL failed as it is "
"not supported by the server\n");
} }
#endif #endif
@ -380,9 +390,7 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
smtp_auth_mechanism = AUTH_PLAIN; smtp_auth_mechanism = AUTH_PLAIN;
} }
if ((miscptr != NULL) && (strlen(miscptr) > 0)) { if ((miscptr != NULL) && (strlen(miscptr) > 0)) {
if (strstr(miscptr, "LOGIN")) if (strstr(miscptr, "LOGIN"))
smtp_auth_mechanism = AUTH_LOGIN; smtp_auth_mechanism = AUTH_LOGIN;
@ -399,7 +407,6 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
if (strstr(miscptr, "NTLM")) if (strstr(miscptr, "NTLM"))
smtp_auth_mechanism = AUTH_NTLM; smtp_auth_mechanism = AUTH_NTLM;
} }
if (verbose) { if (verbose) {
@ -426,15 +433,21 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
free(buf); free(buf);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_smtp(sock, ip, port, options, miscptr, fp); next_run = start_smtp(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) { if (sock >= 0) {
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
} }
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 4: /* error exit */
if (sock >= 0) {
sock = hydra_disconnect(sock);
}
hydra_child_exit(3);
return;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0); hydra_child_exit(0);
@ -443,13 +456,13 @@ void service_smtp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
int32_t service_smtp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_smtp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -457,8 +470,10 @@ int32_t service_smtp_init(char *ip, int32_t sp, unsigned char options, char *mis
return 0; return 0;
} }
void usage_smtp(const char* service) { void usage_smtp(const char *service) {
printf("Module smtp is optionally taking one authentication type of:\n" printf("Module smtp is optionally taking one authentication type of:\n"
" LOGIN (default), PLAIN, CRAM-MD5, DIGEST-MD5, NTLM\n\n" " LOGIN (default), PLAIN, CRAM-MD5, DIGEST-MD5, NTLM\n\n"
"Additionally TLS encryption via STARTTLS can be enforced with the TLS option.\n\n" "Example: smtp://target/TLS:PLAIN\n"); "Additionally TLS encryption via STARTTLS can be enforced with the "
"TLS option.\n\n"
"Example: smtp://target/TLS:PLAIN\n");
} }

View file

@ -1,10 +1,10 @@
#include "hydra-mod.h" #include "hydra-mod.h"
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
#include <openssl/aes.h>
#include <openssl/des.h>
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/des.h>
#include <openssl/aes.h>
#endif #endif
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec); extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
@ -15,31 +15,13 @@ extern int32_t child_head_no;
char snmpv3buf[1024], *snmpv3info = NULL; char snmpv3buf[1024], *snmpv3info = NULL;
int32_t snmpv3infolen = 0, snmpversion = 1, snmpread = 1, hashtype = 1, enctype = 0; int32_t snmpv3infolen = 0, snmpversion = 1, snmpread = 1, hashtype = 1, enctype = 0;
unsigned char snmpv3_init[] = { 0x30, 0x3e, 0x02, 0x01, 0x03, 0x30, 0x11, 0x02, unsigned char snmpv3_init[] = {0x30, 0x3e, 0x02, 0x01, 0x03, 0x30, 0x11, 0x02, 0x04, 0x08, 0x86, 0xdd, 0xf0, 0x02, 0x03, 0x00, 0xff, 0xe3, 0x04, 0x01, 0x04, 0x02, 0x01, 0x03, 0x04, 0x10, 0x30, 0x0e, 0x04, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x30, 0x14, 0x04, 0x00, 0x04, 0x00, 0xa0, 0x0e, 0x02, 0x04, 0x3f, 0x44, 0x5c, 0xbc, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x30, 0x00};
0x04, 0x08, 0x86, 0xdd, 0xf0, 0x02, 0x03, 0x00,
0xff, 0xe3, 0x04, 0x01, 0x04, 0x02, 0x01, 0x03,
0x04, 0x10, 0x30, 0x0e, 0x04, 0x00, 0x02, 0x01,
0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00,
0x04, 0x00, 0x30, 0x14, 0x04, 0x00, 0x04, 0x00,
0xa0, 0x0e, 0x02, 0x04, 0x3f, 0x44, 0x5c, 0xbc,
0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x30, 0x00
};
unsigned char snmpv3_get1[] = { 0x30, 0x77, 0x02, 0x01, 0x03, 0x30, 0x11, 0x02, unsigned char snmpv3_get1[] = {0x30, 0x77, 0x02, 0x01, 0x03, 0x30, 0x11, 0x02, 0x04, 0x08, 0x86, 0xdd, 0xef, 0x02, 0x03, 0x00, 0xff, 0xe3, 0x04, 0x01, 0x05, 0x02, 0x01, 0x03};
0x04, 0x08, 0x86, 0xdd, 0xef, 0x02, 0x03, 0x00,
0xff, 0xe3, 0x04, 0x01, 0x05, 0x02, 0x01, 0x03
};
unsigned char snmpv3_get2[] = { 0x30, 0x2e, 0x04, 0x0c, 0x80, 0x00, 0x00, unsigned char snmpv3_get2[] = {0x30, 0x2e, 0x04, 0x0c, 0x80, 0x00, 0x00, 0x09, 0x03, 0x00, 0x00, 0x1f, 0xca, 0x8d, 0x82, 0x1b, 0x04, 0x00, 0xa0, 0x1c, 0x02, 0x04, 0x3f, 0x44, 0x5c, 0xbb, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x30, 0x0c, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00, 0x05, 0x00};
0x09, 0x03, 0x00, 0x00, 0x1f, 0xca, 0x8d, 0x82,
0x1b, 0x04, 0x00, 0xa0, 0x1c, 0x02, 0x04, 0x3f,
0x44, 0x5c, 0xbb, 0x02, 0x01, 0x00, 0x02, 0x01,
0x00, 0x30, 0x0e, 0x30, 0x0c, 0x06, 0x08, 0x2b,
0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00, 0x05,
0x00
};
unsigned char snmpv3_nouser[] = { 0x04, 0x00, 0x04, 0x00, 0x04, 0x00 }; unsigned char snmpv3_nouser[] = {0x04, 0x00, 0x04, 0x00, 0x04, 0x00};
struct SNMPV1_A { struct SNMPV1_A {
char ID; char ID;
@ -49,13 +31,11 @@ struct SNMPV1_A {
char comlen; char comlen;
}; };
struct SNMPV1_A snmpv1_a = { struct SNMPV1_A snmpv1_a = {.ID = '\x30',
.ID = '\x30', .len = '\x00',
.len = '\x00', .ver = "\x02\x01\x00", /* \x02\x01\x01 for snmpv2c, \x02\x01\x03 for snmpv3 */
.ver = "\x02\x01\x00", /* \x02\x01\x01 for snmpv2c, \x02\x01\x03 for snmpv3 */ .comid = '\x04',
.comid = '\x04', .comlen = '\x00'};
.comlen = '\x00'
};
struct SNMPV1_R { struct SNMPV1_R {
unsigned char type[2]; unsigned char type[2];
@ -67,12 +47,14 @@ struct SNMPV1_R {
unsigned char object[11]; unsigned char object[11];
unsigned char value[3]; unsigned char value[3];
} snmpv1_r = { } snmpv1_r = {
.type = "\xa0\x1b", /* GET */ .type = "\xa0\x1b", /* GET */
.identid = "\x02\x04",.ident = "\x1a\x5e\x97\x00", /* random crap :) */ .identid = "\x02\x04",
.errstat = "\x02\x01\x00", /* no error */ .ident = "\x1a\x5e\x97\x00", /* random crap :) */
.errind = "\x02\x01\x00", /* error index 0 */ .errstat = "\x02\x01\x00", /* no error */
.objectid = "\x30\x0d",.object = "\x30\x0b\x06\x07\x2b\x06\x01\x02\x01\x01\x01", /* sysDescr */ .errind = "\x02\x01\x00", /* error index 0 */
.value = "\x05\x00" /* we just read, so value = 0 */ .objectid = "\x30\x0d",
.object = "\x30\x0b\x06\x07\x2b\x06\x01\x02\x01\x01\x01", /* sysDescr */
.value = "\x05\x00" /* we just read, so value = 0 */
}; };
struct SNMPV1_W { struct SNMPV1_W {
@ -85,20 +67,22 @@ struct SNMPV1_W {
unsigned char object[12]; unsigned char object[12];
unsigned char value[8]; unsigned char value[8];
} snmpv1_w = { } snmpv1_w = {
.type = "\xa3\x21", /* SET */ .type = "\xa3\x21", /* SET */
.identid = "\x02\x04",.ident = "\x1a\x5e\x97\x22", /* random crap :) */ .identid = "\x02\x04",
.errstat = "\x02\x01\x00", /* no error */ .ident = "\x1a\x5e\x97\x22", /* random crap :) */
.errind = "\x02\x01\x00", /* error index 0 */ .errstat = "\x02\x01\x00", /* no error */
.objectid = "\x30\x13", /* string */ .errind = "\x02\x01\x00", /* error index 0 */
.object = "\x30\x11\x06\x08\x2b\x06\x01\x02\x01\x01\x05\x00",.value = "\x04\x05Hydra" /* writing hydra :-) */ .objectid = "\x30\x13", /* string */
.object = "\x30\x11\x06\x08\x2b\x06\x01\x02\x01\x01\x05\x00",
.value = "\x04\x05Hydra" /* writing hydra :-) */
}; };
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
void password_to_key_md5(u_char * password, /* IN */ void password_to_key_md5(u_char *password, /* IN */
u_int passwordlen, /* IN */ u_int passwordlen, /* IN */
u_char * engineID, /* IN - pointer to snmpEngineID */ u_char *engineID, /* IN - pointer to snmpEngineID */
u_int engineLength, /* IN - length of snmpEngineID */ u_int engineLength, /* IN - length of snmpEngineID */
u_char * key) { /* OUT - pointer to caller 16-octet buffer */ u_char *key) { /* OUT - pointer to caller 16-octet buffer */
MD5_CTX MD; MD5_CTX MD;
u_char *cp, password_buf[80], *mypass = password, bpass[17]; u_char *cp, password_buf[80], *mypass = password, bpass[17];
u_long password_index = 0, count = 0, i, mylen, myelen = engineLength; u_long password_index = 0, count = 0, i, mylen, myelen = engineLength;
@ -111,7 +95,7 @@ void password_to_key_md5(u_char * password, /* IN */
if (mylen < 8) { if (mylen < 8) {
memset(bpass, 0, sizeof(bpass)); memset(bpass, 0, sizeof(bpass));
strcpy(bpass, password); strncpy(bpass, password, sizeof(bpass) - 1);
while (mylen < 8) { while (mylen < 8) {
strcat(bpass, password); strcat(bpass, password);
mylen += passwordlen; mylen += passwordlen;
@ -121,7 +105,7 @@ void password_to_key_md5(u_char * password, /* IN */
if (myelen > 32) if (myelen > 32)
myelen = 32; myelen = 32;
MD5_Init(&MD); /* initialize MD5 */ MD5_Init(&MD); /* initialize MD5 */
/* Use while loop until we've done 1 Megabyte */ /* Use while loop until we've done 1 Megabyte */
while (count < 1048576) { while (count < 1048576) {
cp = password_buf; cp = password_buf;
@ -133,7 +117,7 @@ void password_to_key_md5(u_char * password, /* IN */
MD5_Update(&MD, password_buf, 64); MD5_Update(&MD, password_buf, 64);
count += 64; count += 64;
} }
MD5_Final(key, &MD); /* tell MD5 we're done */ MD5_Final(key, &MD); /* tell MD5 we're done */
/* Now localize the key with the engineID and pass */ /* Now localize the key with the engineID and pass */
/* through MD5 to produce final key */ /* through MD5 to produce final key */
/* May want to ensure that engineLength <= 32, */ /* May want to ensure that engineLength <= 32, */
@ -147,11 +131,11 @@ void password_to_key_md5(u_char * password, /* IN */
return; return;
} }
void password_to_key_sha(u_char * password, /* IN */ void password_to_key_sha(u_char *password, /* IN */
u_int passwordlen, /* IN */ u_int passwordlen, /* IN */
u_char * engineID, /* IN - pointer to snmpEngineID */ u_char *engineID, /* IN - pointer to snmpEngineID */
u_int engineLength, /* IN - length of snmpEngineID */ u_int engineLength, /* IN - length of snmpEngineID */
u_char * key) { /* OUT - pointer to caller 20-octet buffer */ u_char *key) { /* OUT - pointer to caller 20-octet buffer */
SHA_CTX SH; SHA_CTX SH;
u_char *cp, password_buf[80], *mypass = password, bpass[17]; u_char *cp, password_buf[80], *mypass = password, bpass[17];
u_long password_index = 0, count = 0, i, mylen = passwordlen, myelen = engineLength; u_long password_index = 0, count = 0, i, mylen = passwordlen, myelen = engineLength;
@ -169,7 +153,7 @@ void password_to_key_sha(u_char * password, /* IN */
if (myelen > 32) if (myelen > 32)
myelen = 32; myelen = 32;
SHA1_Init(&SH); /* initialize SHA */ SHA1_Init(&SH); /* initialize SHA */
/* Use while loop until we've done 1 Megabyte */ /* Use while loop until we've done 1 Megabyte */
while (count < 1048576) { while (count < 1048576) {
cp = password_buf; cp = password_buf;
@ -181,7 +165,7 @@ void password_to_key_sha(u_char * password, /* IN */
SHA1_Update(&SH, password_buf, 64); SHA1_Update(&SH, password_buf, 64);
count += 64; count += 64;
} }
SHA1_Final(key, &SH); /* tell SHA we're done */ SHA1_Final(key, &SH); /* tell SHA we're done */
/* Now localize the key with the engineID and pass */ /* Now localize the key with the engineID and pass */
/* through SHA to produce final key */ /* through SHA to produce final key */
/* May want to ensure that engineLength <= 32, */ /* May want to ensure that engineLength <= 32, */
@ -196,7 +180,7 @@ void password_to_key_sha(u_char * password, /* IN */
} }
#endif #endif
int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\"", *ptr, *login, *pass, buffer[1024], buf[1024], hash[64], key[256] = "", salt[8] = ""; char *empty = "\"\"", *ptr, *login, *pass, buffer[1024], buf[1024], hash[64], key[256] = "", salt[8] = "";
int32_t i, j, k, size, off = 0, off2 = 0; int32_t i, j, k, size, off = 0, off2 = 0;
unsigned char initVect[8], privacy_params[8]; unsigned char initVect[8], privacy_params[8];
@ -223,7 +207,7 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
size = sizeof(snmpv1_w); size = sizeof(snmpv1_w);
} }
snmpv1_a.comlen = (char) strlen(pass); snmpv1_a.comlen = (char)strlen(pass);
snmpv1_a.len = snmpv1_a.comlen + size + sizeof(snmpv1_a) - 3; snmpv1_a.len = snmpv1_a.comlen + size + sizeof(snmpv1_a) - 3;
i = sizeof(snmpv1_a); i = sizeof(snmpv1_a);
@ -238,7 +222,7 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
memcpy(buffer + i, &snmpv1_w, size); memcpy(buffer + i, &snmpv1_w, size);
i += sizeof(snmpv1_w); i += sizeof(snmpv1_w);
} }
} else { // snmpv3 } else { // snmpv3
if (enctype == 0) { if (enctype == 0) {
memcpy(buffer, snmpv3_get1, sizeof(snmpv3_get1)); memcpy(buffer, snmpv3_get1, sizeof(snmpv3_get1));
i = sizeof(snmpv3_get1); i = sizeof(snmpv3_get1);
@ -277,7 +261,8 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
if (enctype == 0) if (enctype == 0)
buffer[1] = 48 + sizeof(snmpv3_get1) + buffer[i + 1]; buffer[1] = 48 + sizeof(snmpv3_get1) + buffer[i + 1];
i += snmpv3infolen; i += snmpv3infolen;
//printf("2 + %d + %d + %d = 0x%02x\n", off, snmpv3infolen, strlen(login), buffer[1]); // printf("2 + %d + %d + %d = 0x%02x\n", off, snmpv3infolen, strlen(login),
// buffer[1]);
buffer[i] = 0x04; buffer[i] = 0x04;
buffer[i + 1] = strlen(login); buffer[i + 1] = strlen(login);
@ -301,7 +286,7 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
i += 2; i += 2;
} else { } else {
buffer[i + 1] = 8; buffer[i + 1] = 8;
memcpy(buffer + i + 2, salt, 8); // uninitialized and we don't care memcpy(buffer + i + 2, salt, 8); // uninitialized and we don't care
i += 10; i += 10;
} }
@ -314,49 +299,49 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
/* /*
//PrivDES::encrypt(const unsigned char *key, //PrivDES::encrypt(const unsigned char *key,
// const uint32_t key_len, // const uint32_t key_len,
// const unsigned char *buffer, // const unsigned char *buffer,
// const uint32_t buffer_len, // const uint32_t buffer_len,
// unsigned char *out_buffer, // unsigned char *out_buffer,
// uint32_t *out_buffer_len, // uint32_t *out_buffer_len,
// unsigned char *privacy_params, // unsigned char *privacy_params,
// uint32_t *privacy_params_len, // uint32_t *privacy_params_len,
// const unsigned long engine_boots, // const unsigned long engine_boots,
// const unsigned long engine_time) // const unsigned long engine_time)
// last 8 bytes of key are used as base for initialization vector */ // last 8 bytes of key are used as base for initialization vector */
k = 0; k = 0;
memcpy((char *) initVect, key + 8, 8); memcpy((char *)initVect, key + 8, 8);
// put salt in privacy_params // put salt in privacy_params
j = htonl(engine_boots); j = htonl(engine_boots);
memcpy(privacy_params, (char *) &j, 4); memcpy(privacy_params, (char *)&j, 4);
memcpy(privacy_params + 4, salt, 4); // ??? correct? memcpy(privacy_params + 4, salt, 4); // ??? correct?
// xor initVect with salt // xor initVect with salt
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
initVect[i] ^= privacy_params[i]; initVect[i] ^= privacy_params[i];
DES_key_sched((const_DES_cblock *) key, &symcbc); DES_key_sched((const_DES_cblock *)key, &symcbc);
DES_ncbc_encrypt(snmpv3_get2 + 2, buf, sizeof(snmpv3_get2) - 2, &symcbc, (const_DES_cblock *) (initVect), DES_ENCRYPT); DES_ncbc_encrypt(snmpv3_get2 + 2, buf, sizeof(snmpv3_get2) - 2, &symcbc, (const_DES_cblock *)(initVect), DES_ENCRYPT);
#endif #endif
/* for (i = 0; i <= sizeof(snmpv3_get2) - 8; i += 8) { /* for (i = 0; i <= sizeof(snmpv3_get2) - 8; i += 8) {
DES_ncbc_encrypt(snmpv3_get2 + i, buf + i, 8, (const_DES_cblock*)(initVect), DES_ENCRYPT); DES_ncbc_encrypt(snmpv3_get2 + i, buf + i, 8,
} (const_DES_cblock*)(initVect), DES_ENCRYPT);
// last part of buffer }
if (buffer_len % 8) { // last part of buffer
unsigned char tmp_buf[8]; if (buffer_len % 8) {
unsigned char *tmp_buf_ptr = tmp_buf; unsigned char tmp_buf[8];
int32_t start = buffer_len - (buffer_len % 8); unsigned char *tmp_buf_ptr = tmp_buf;
memset(tmp_buf, 0, 8); int32_t start = buffer_len - (buffer_len % 8);
for (uint32_t l = start; l < buffer_len; l++) memset(tmp_buf, 0, 8);
*tmp_buf_ptr++ = buffer[l]; for (uint32_t l = start; l < buffer_len; l++)
DES_ncbc_encrypt(tmp_buf, buf + start, 1, &symcbc, (const_DES_cblock*)(initVect), DES_ENCRYPT); *tmp_buf_ptr++ = buffer[l];
*out_buffer_len = buffer_len + 8 - (buffer_len % 8); DES_ncbc_encrypt(tmp_buf, buf + start, 1, &symcbc,
} else (const_DES_cblock*)(initVect), DES_ENCRYPT); *out_buffer_len =
*out_buffer_len = buffer_len; buffer_len + 8 - (buffer_len % 8); } else *out_buffer_len = buffer_len;
*/ */
//dummy // dummy
k = ((sizeof(snmpv3_get2) - 2) / 8); k = ((sizeof(snmpv3_get2) - 2) / 8);
if ((sizeof(snmpv3_get2) - 2) % 8 != 0) if ((sizeof(snmpv3_get2) - 2) % 8 != 0)
k++; k++;
@ -364,13 +349,13 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
i += k * 8 + 2; i += k * 8 + 2;
} }
i++; // just to conform with the snmpv1/2 code i++; // just to conform with the snmpv1/2 code
#ifdef LIBOPENSSL #ifdef LIBOPENSSL
if (hashtype == 1) { if (hashtype == 1) {
HMAC((EVP_MD *) EVP_md5(), key, 16, buffer, i - 1, hash, NULL); HMAC((EVP_MD *)EVP_md5(), key, 16, buffer, i - 1, hash, NULL);
memcpy(buffer + off, hash, 12); memcpy(buffer + off, hash, 12);
} else if (hashtype == 2) { } else if (hashtype == 2) {
HMAC((EVP_MD *) EVP_sha1(), key, 20, buffer, i - 1, hash, NULL); HMAC((EVP_MD *)EVP_sha1(), key, 20, buffer, i - 1, hash, NULL);
memcpy(buffer + off, hash, 12); memcpy(buffer + off, hash, 12);
} }
#endif #endif
@ -384,19 +369,19 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} while (hydra_data_ready_timed(s, 1, 0) <= 0 && j < 3); } while (hydra_data_ready_timed(s, 1, 0) <= 0 && j < 3);
if (hydra_data_ready_timed(s, 5, 0) > 0) { if (hydra_data_ready_timed(s, 5, 0) > 0) {
i = hydra_recv(s, (char *) buf, sizeof(buf)); i = hydra_recv(s, (char *)buf, sizeof(buf));
if (snmpversion < 3) { if (snmpversion < 3) {
/* stolen from ADMsnmp... :P */ /* stolen from ADMsnmp... :P */
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (buf[j] == '\x04') { /* community name */ if (buf[j] == '\x04') { /* community name */
for (j = j + buf[j + 1]; j + 2 < i; j++) { for (j = j + buf[j + 1]; j + 2 < i; j++) {
if (buf[j] == '\xa2') { /* PDU Response */ if (buf[j] == '\xa2') { /* PDU Response */
for (; j + 2 < i; j++) { for (; j + 2 < i; j++) {
if (buf[j] == '\x02') { /* ID */ if (buf[j] == '\x02') { /* ID */
for (j = j + (buf[j + 1]); j + 2 < i; j++) { for (j = j + (buf[j + 1]); j + 2 < i; j++) {
if (buf[j] == '\x02') { if (buf[j] == '\x02') {
if (buf[j + 1] == '\x01') { /* good ! */ if (buf[j + 1] == '\x01') { /* good ! */
hydra_report_found_host(port, ip, "snmp", fp); hydra_report_found_host(port, ip, "snmp", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
@ -411,7 +396,7 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
} }
} }
} }
} else { // snmpv3 reply } else { // snmpv3 reply
off = 0; off = 0;
if (buf[0] == 0x30) { if (buf[0] == 0x30) {
if (buf[4] == 0x03 && buf[5] == 0x30) if (buf[4] == 0x03 && buf[5] == 0x30)
@ -453,7 +438,8 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
return 1; return 1;
} else if ((buf[off + 15] & 5) == 4 && hydra_memsearch(buf, i, snmpv3_nouser, sizeof(snmpv3_nouser)) >= 0) { // user does not exist } else if ((buf[off + 15] & 5) == 4 && hydra_memsearch(buf, i, snmpv3_nouser,
sizeof(snmpv3_nouser)) >= 0) { // user does not exist
if (verbose) if (verbose)
printf("[INFO] user %s does not exist, skipping\n", login); printf("[INFO] user %s does not exist, skipping\n", login);
hydra_completed_pair_skip(); hydra_completed_pair_skip();
@ -470,7 +456,7 @@ int32_t start_snmp(int32_t s, char *ip, int32_t port, unsigned char options, cha
return 1; return 1;
} }
void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1, i = 0; int32_t run = 1, next_run = 1, sock = -1, i = 0;
int32_t myport = PORT_SNMP; int32_t myport = PORT_SNMP;
char *lptr; char *lptr;
@ -519,7 +505,7 @@ void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
hydra_register_socket(sp); hydra_register_socket(sp);
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, no socket available\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, no socket available\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -528,7 +514,7 @@ void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
while (snmpv3info == NULL && next_run < 3) { while (snmpv3info == NULL && next_run < 3) {
hydra_send(sock, snmpv3_init, sizeof(snmpv3_init), 0); hydra_send(sock, snmpv3_init, sizeof(snmpv3_init), 0);
if (hydra_data_ready_timed(sock, 5, 0) > 0) { if (hydra_data_ready_timed(sock, 5, 0) > 0) {
if ((i = hydra_recv(sock, (char *) snmpv3buf, sizeof(snmpv3buf))) > 30) { if ((i = hydra_recv(sock, (char *)snmpv3buf, sizeof(snmpv3buf))) > 30) {
if (snmpv3buf[4] == 3 && snmpv3buf[5] == 0x30) { if (snmpv3buf[4] == 3 && snmpv3buf[5] == 0x30) {
snmpv3info = snmpv3buf + 7 + snmpv3buf[6]; snmpv3info = snmpv3buf + 7 + snmpv3buf[6];
snmpv3infolen = snmpv3info[3] + 4; snmpv3infolen = snmpv3info[3] + 4;
@ -538,8 +524,9 @@ void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
if (debug) if (debug)
hydra_dump_asciihex(snmpv3info, snmpv3infolen); hydra_dump_asciihex(snmpv3info, snmpv3infolen);
if (snmpv3info[10] == 3 && child_head_no == 0) if (snmpv3info[10] == 3 && child_head_no == 0)
printf("[INFO] Remote device MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", (unsigned char) snmpv3info[12], (unsigned char) snmpv3info[13], printf("[INFO] Remote device MAC address is "
(unsigned char) snmpv3info[14], (unsigned char) snmpv3info[15], (unsigned char) snmpv3info[16], (unsigned char) snmpv3info[12]); "%02x:%02x:%02x:%02x:%02x:%02x\n",
(unsigned char)snmpv3info[12], (unsigned char)snmpv3info[13], (unsigned char)snmpv3info[14], (unsigned char)snmpv3info[15], (unsigned char)snmpv3info[16], (unsigned char)snmpv3info[12]);
} }
} }
} }
@ -557,10 +544,10 @@ void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
next_run = start_snmp(sock, ip, port, options, miscptr, fp); next_run = start_snmp(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -573,13 +560,13 @@ void service_snmp(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} }
} }
int32_t service_snmp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_snmp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -587,20 +574,22 @@ int32_t service_snmp_init(char *ip, int32_t sp, unsigned char options, char *mis
return 0; return 0;
} }
void usage_snmp(const char* service) { void usage_snmp(const char *service) {
printf("Module snmp is optionally taking the following parameters:\n" printf("Module snmp is optionally taking the following parameters:\n"
" READ perform read requests (default)\n" " READ perform read requests (default)\n"
" WRITE perform write requests\n" " WRITE perform write requests\n"
" 1 use SNMP version 1 (default)\n" " 1 use SNMP version 1 (default)\n"
" 2 use SNMP version 2\n" " 2 use SNMP version 2\n"
" 3 use SNMP version 3\n" " 3 use SNMP version 3\n"
" Note that SNMP version 3 usually uses both login and passwords!\n" " Note that SNMP version 3 usually uses both login and "
"passwords!\n"
" SNMP version 3 has the following optional sub parameters:\n" " SNMP version 3 has the following optional sub parameters:\n"
" MD5 use MD5 authentication (default)\n" " MD5 use MD5 authentication (default)\n"
" SHA use SHA authentication\n" " SHA use SHA authentication\n"
" DES use DES encryption\n" " DES use DES encryption\n"
" AES use AES encryption\n" " AES use AES encryption\n"
" if no -p/-P parameter is given, SNMPv3 noauth is performed, which\n" " if no -p/-P parameter is given, SNMPv3 noauth is performed, "
"which\n"
" only requires a password (or username) not both.\n" " only requires a password (or username) not both.\n"
"To combine the options, use colons (\":\"), e.g.:\n" "To combine the options, use colons (\":\"), e.g.:\n"
" hydra -L user.txt -P pass.txt -m 3:SHA:AES:READ target.com snmp\n" " hydra -L user.txt -P pass.txt -m 3:SHA:AES:READ target.com snmp\n"

View file

@ -14,7 +14,7 @@ unsigned char *buf;
int32_t fail_cnt; int32_t fail_cnt;
int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[300]; char *login, *pass, buffer[300];
int32_t pport, fud = 0; int32_t pport, fud = 0;
@ -28,7 +28,7 @@ int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, c
if (hydra_send(s, buffer, 4, 0) < 0) { if (hydra_send(s, buffer, 4, 0) < 0) {
return 1; return 1;
} }
if ((buf = (unsigned char *) hydra_receive_line(s)) == NULL) { if ((buf = (unsigned char *)hydra_receive_line(s)) == NULL) {
fail_cnt++; fail_cnt++;
if (fail_cnt >= 10) if (fail_cnt >= 10)
return 5; return 5;
@ -57,16 +57,16 @@ int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, c
} }
free(buf); free(buf);
/* RFC 1929 /* RFC 1929
For username/password authentication the client's authentication request is For username/password authentication the client's authentication request is
field 1: version number, 1 byte (must be 0x01) field 1: version number, 1 byte (must be 0x01)
*/ */
snprintf(buffer, sizeof(buffer), "\x01%c%s%c%s", (char) strlen(login), login, (char) strlen(pass), pass); snprintf(buffer, sizeof(buffer), "\x01%c%s%c%s", (char)strlen(login), login, (char)strlen(pass), pass);
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) if (hydra_send(s, buffer, strlen(buffer), 0) < 0)
return 1; return 1;
if ((buf = (unsigned char *) hydra_receive_line(s)) == NULL) if ((buf = (unsigned char *)hydra_receive_line(s)) == NULL)
return (1); return (1);
if (buf[1] != 255) { if (buf[1] != 255) {
@ -84,7 +84,7 @@ int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, c
memcpy(buffer + 8, &pport, 2); memcpy(buffer + 8, &pport, 2);
hydra_send(s, buffer, 10, 0); hydra_send(s, buffer, 10, 0);
} }
if ((buf = (unsigned char *) hydra_receive_line(s)) != NULL) { if ((buf = (unsigned char *)hydra_receive_line(s)) != NULL) {
if (buf[1] == 0 || buf[1] == 32) { if (buf[1] == 0 || buf[1] == 32) {
hydra_report_found_host(port, ip, "socks5", fp); hydra_report_found_host(port, ip, "socks5", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
@ -104,7 +104,7 @@ int32_t start_socks5(int32_t s, char *ip, int32_t port, unsigned char options, c
return 2; return 2;
} }
void service_socks5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_socks5(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_SOCKS5, mysslport = PORT_SOCKS5_SSL; int32_t myport = PORT_SOCKS5, mysslport = PORT_SOCKS5_SSL;
@ -116,10 +116,10 @@ void service_socks5(char *ip, int32_t sp, unsigned char options, char *miscptr,
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -133,25 +133,25 @@ void service_socks5(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_socks5(sock, ip, port, options, miscptr, fp); next_run = start_socks5(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 4: /* clean exit */ case 4: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
return; return;
case 5: /* clean exit, server may blocking connections */ case 5: /* clean exit, server may blocking connections */
hydra_report(stderr, "[ERROR] Server may blocking connections\n"); hydra_report(stderr, "[ERROR] Server may blocking connections\n");
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
@ -165,13 +165,13 @@ void service_socks5(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
} }
int32_t service_socks5_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_socks5_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -8,9 +8,7 @@ have to add option -DWITH_SSH1=On in the cmake
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBSSH #ifndef LIBSSH
void dummy_ssh() { void dummy_ssh() { printf("\n"); }
printf("\n");
}
#else #else
#include <libssh/libssh.h> #include <libssh/libssh.h>
@ -23,7 +21,7 @@ extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
int32_t new_session = 1; int32_t new_session = 1;
int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, keep_login[300]; char *login, *pass, keep_login[300];
int32_t auth_state = 0, rc = 0, i = 0; int32_t auth_state = 0, rc = 0, i = 0;
@ -36,11 +34,12 @@ int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char
if (new_session) { if (new_session) {
if (session) { if (session) {
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); // ssh_finalize();
ssh_free(session); ssh_free(session);
} else {
ssh_init();
} }
ssh_init();
session = ssh_new(); session = ssh_new();
ssh_options_set(session, SSH_OPTIONS_PORT, &port); ssh_options_set(session, SSH_OPTIONS_PORT, &port);
ssh_options_set(session, SSH_OPTIONS_HOST, hydra_address2string(ip)); ssh_options_set(session, SSH_OPTIONS_HOST, hydra_address2string(ip));
@ -48,8 +47,11 @@ int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char
ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &hydra_options.waittime); ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &hydra_options.waittime);
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none");
// might be better to add the legacy (first two for KEX and HOST) to the default instead of specifying the full list
ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256");
ssh_options_set(session, SSH_OPTIONS_HOSTKEYS, "ssh-rsa,ssh-dss,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256");
if (ssh_connect(session) != 0) { if (ssh_connect(session) != 0) {
//if the connection was drop, exit and let hydra main handle it // if the connection was drop, exit and let hydra main handle it
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] could not connect to target port %d: %s\n", port, ssh_get_error(session)); hydra_report(stderr, "[ERROR] could not connect to target port %d: %s\n", port, ssh_get_error(session));
return 3; return 3;
@ -110,7 +112,7 @@ int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char
return 1; return 1;
} }
void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
hydra_register_socket(sp); hydra_register_socket(sp);
@ -118,14 +120,17 @@ void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
next_run = start_ssh(sock, ip, port, options, miscptr, fp); next_run = start_ssh(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 2: case 2:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
hydra_child_exit(0); hydra_child_exit(0);
break;
case 3: case 3:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
@ -133,12 +138,14 @@ void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
if (verbose) if (verbose)
fprintf(stderr, "[ERROR] ssh protocol error\n"); fprintf(stderr, "[ERROR] ssh protocol error\n");
hydra_child_exit(2); hydra_child_exit(2);
break;
case 4: case 4:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
fprintf(stderr, "[ERROR] ssh target does not support password auth\n"); fprintf(stderr, "[ERROR] ssh target does not support password auth\n");
hydra_child_exit(2); hydra_child_exit(2);
break;
default: default:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
@ -155,16 +162,16 @@ void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
#endif #endif
// //
// dirty workaround here: miscptr is the ptr to the logins, and the first one is used // dirty workaround here: miscptr is the ptr to the logins, and the first one is
// to test if password authentication is enabled!! // used to test if password authentication is enabled!!
// //
int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// 1 skip target without generating an error // 1 skip target without generating an error
@ -172,10 +179,13 @@ int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *misc
// 3 skip target because its unreachable // 3 skip target because its unreachable
#ifdef LIBSSH #ifdef LIBSSH
int32_t rc, method; int32_t rc, method;
ssh_init();
ssh_session session = ssh_new(); ssh_session session = ssh_new();
if (verbose || debug) if (verbose || debug)
printf("[INFO] Testing if password authentication is supported by ssh://%s@%s:%d\n", miscptr == NULL ? "hydra" : miscptr, hydra_address2string_beautiful(ip), port); printf("[INFO] Testing if password authentication is supported by "
"ssh://%s@%s:%d\n",
miscptr == NULL ? "hydra" : miscptr, hydra_address2string_beautiful(ip), port);
ssh_options_set(session, SSH_OPTIONS_PORT, &port); ssh_options_set(session, SSH_OPTIONS_PORT, &port);
ssh_options_set(session, SSH_OPTIONS_HOST, hydra_address2string(ip)); ssh_options_set(session, SSH_OPTIONS_HOST, hydra_address2string(ip));
if (miscptr == NULL) if (miscptr == NULL)
@ -185,29 +195,41 @@ int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *misc
ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &hydra_options.waittime); ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &hydra_options.waittime);
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none");
// might be better to add the legacy (first two for KEX and HOST) to the default instead of specifying the full list
ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256");
ssh_options_set(session, SSH_OPTIONS_HOSTKEYS, "ssh-rsa,ssh-dss,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256");
if (ssh_connect(session) != 0) { if (ssh_connect(session) != 0) {
fprintf(stderr, "[ERROR] could not connect to ssh://%s:%d - %s\n", hydra_address2string_beautiful(ip), port, ssh_get_error(session)); fprintf(stderr, "[ERROR] could not connect to ssh://%s:%d - %s\n", hydra_address2string_beautiful(ip), port, ssh_get_error(session));
return 2; return 2;
} }
rc = ssh_userauth_none(session, NULL); rc = ssh_userauth_none(session, NULL);
method = ssh_userauth_list(session, NULL); method = ssh_userauth_list(session, NULL);
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
if (debug) printf("[DEBUG] SSH method check: %08x\n", method); if (debug)
printf("[DEBUG] SSH method check: %08x\n", method);
if ((method & SSH_AUTH_METHOD_INTERACTIVE) || (method & SSH_AUTH_METHOD_PASSWORD)) { if ((method & SSH_AUTH_METHOD_INTERACTIVE) || (method & SSH_AUTH_METHOD_PASSWORD)) {
if (verbose || debug) if (verbose || debug)
printf("[INFO] Successful, password authentication is supported by ssh://%s:%d\n", hydra_address2string_beautiful(ip), port); printf("[INFO] Successful, password authentication is supported by "
"ssh://%s:%d\n",
hydra_address2string_beautiful(ip), port);
return 0; return 0;
} else if (method == 0) { } else if (method == 0) {
if (verbose || debug) if (verbose || debug)
fprintf(stderr, "[WARNING] invalid SSH method reply from ssh://%s:%d, continuing anyway ... (check for empty password!)\n", hydra_address2string_beautiful(ip), port); fprintf(stderr,
"[WARNING] invalid SSH method reply from ssh://%s:%d, continuing "
"anyway ... (check for empty password!)\n",
hydra_address2string_beautiful(ip), port);
return 0; return 0;
} }
fprintf(stderr, "[ERROR] target ssh://%s:%d/ does not support password authentication (method reply %d).\n", hydra_address2string_beautiful(ip), port, method); fprintf(stderr,
"[ERROR] target ssh://%s:%d/ does not support password "
"authentication (method reply %d).\n",
hydra_address2string_beautiful(ip), port, method);
return 1; return 1;
#else #else
return 0; return 0;

View file

@ -1,16 +1,14 @@
/* /*
libssh is available at http://www.libssh.org libssh is available at http://www.libssh.org
current version is 0.4.8 current version is 0.4.8
If you want support for ssh v1 protocol, you If you want support for ssh v1 protocol, you
have to add option -DWITH_SSH1=On in the cmake have to add option -DWITH_SSH1=On in the cmake
*/ */
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBSSH #ifndef LIBSSH
void dummy_sshkey() { void dummy_sshkey() { printf("\n"); }
printf("\n");
}
#else #else
#include <libssh/libssh.h> #include <libssh/libssh.h>
@ -18,10 +16,11 @@ void dummy_sshkey() {
#if LIBSSH_VERSION_MAJOR >= 0 && LIBSSH_VERSION_MINOR >= 4 #if LIBSSH_VERSION_MAJOR >= 0 && LIBSSH_VERSION_MINOR >= 4
extern ssh_session session; extern ssh_session session;
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
extern int32_t new_session; extern int32_t new_session;
int32_t start_sshkey(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_sshkey(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *key, keep_login[300]; char *login, *key, keep_login[300];
int32_t auth_state = 0, rc = 0; int32_t auth_state = 0, rc = 0;
@ -35,8 +34,9 @@ int32_t start_sshkey(int32_t s, char *ip, int32_t port, unsigned char options, c
if (new_session) { if (new_session) {
if (session) { if (session) {
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize();
ssh_free(session); ssh_free(session);
} else {
ssh_init();
} }
session = ssh_new(); session = ssh_new();
@ -46,7 +46,7 @@ int32_t start_sshkey(int32_t s, char *ip, int32_t port, unsigned char options, c
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "none");
ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none"); ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "none");
if (ssh_connect(session) != 0) { if (ssh_connect(session) != 0) {
//if the connection was drop, exit and let hydra main handle it // if the connection was drop, exit and let hydra main handle it
if (verbose) if (verbose)
hydra_report(stderr, "[ERROR] could not connect to target port %d\n", port); hydra_report(stderr, "[ERROR] could not connect to target port %d\n", port);
return 3; return 3;
@ -108,7 +108,7 @@ int32_t start_sshkey(int32_t s, char *ip, int32_t port, unsigned char options, c
return 1; return 1;
} }
void service_sshkey(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_sshkey(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
hydra_register_socket(sp); hydra_register_socket(sp);
@ -116,26 +116,31 @@ void service_sshkey(char *ip, int32_t sp, unsigned char options, char *miscptr,
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
next_run = start_sshkey(sock, ip, port, options, miscptr, fp); next_run = start_sshkey(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 2: case 2:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
hydra_child_exit(0); hydra_child_exit(0);
break;
case 3: case 3:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
fprintf(stderr, "[ERROR] ssh protocol error\n"); fprintf(stderr, "[ERROR] ssh protocol error\n");
hydra_child_exit(2); hydra_child_exit(2);
break;
case 4: case 4:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
ssh_free(session); ssh_free(session);
fprintf(stderr, "[ERROR] ssh target does not support pubkey auth\n"); fprintf(stderr, "[ERROR] ssh target does not support pubkey auth\n");
hydra_child_exit(2); hydra_child_exit(2);
break;
default: default:
ssh_disconnect(session); ssh_disconnect(session);
ssh_finalize(); ssh_finalize();
@ -151,13 +156,13 @@ void service_sshkey(char *ip, int32_t sp, unsigned char options, char *miscptr,
#endif #endif
#endif #endif
int32_t service_sshkey_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_sshkey_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -165,9 +170,11 @@ int32_t service_sshkey_init(char *ip, int32_t sp, unsigned char options, char *m
return 0; return 0;
} }
void usage_sshkey(const char* service) { void usage_sshkey(const char *service) {
printf("Module sshkey does not provide additional options, although the semantic for\n" printf("Module sshkey does not provide additional options, although the "
"semantic for\n"
"options -p and -P is changed:\n" "options -p and -P is changed:\n"
" -p expects a path to an unencrypted private key in PEM format.\n" " -p expects a path to an unencrypted private key in PEM format.\n"
" -P expects a filename containing a list of path to some unencrypted\n" " private keys in PEM format.\n\n"); " -P expects a filename containing a list of path to some unencrypted\n"
" private keys in PEM format.\n\n");
} }

View file

@ -1,39 +1,45 @@
//This plugin was written by <david dot maciejak at gmail D O T com> // This plugin was written by <david dot maciejak at gmail D O T com>
//checked for memleaks on 110425, none found // checked for memleaks on 110425, none found
#ifdef LIBSVN #ifdef LIBSVN
/* needed on openSUSE */ /* needed on openSUSE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#if !defined PATH_MAX && defined HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <svn_client.h> #include <svn_client.h>
#include <svn_cmdline.h> #include <svn_cmdline.h>
#include <svn_pools.h>
#include <svn_config.h> #include <svn_config.h>
#include <svn_fs.h> #include <svn_fs.h>
#include <svn_pools.h>
#include <svn_version.h>
#if SVN_VER_MINOR > 7
#include <svn_path.h> #include <svn_path.h>
#endif
#endif #endif
#include "hydra-mod.h" #include "hydra-mod.h"
#ifndef LIBSVN #ifndef LIBSVN
void dummy_svn() { void dummy_svn() { printf("\n"); }
printf("\n");
}
#else #else
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec); extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern hydra_option hydra_options;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
#define DEFAULT_BRANCH "trunk" #define DEFAULT_BRANCH "trunk"
static svn_error_t *print_dirdummy(void *baton, const char *path, const svn_dirent_t * dirent, const svn_lock_t * lock, const char *abs_path, apr_pool_t * pool) { static svn_error_t *print_dirdummy(void *baton, const char *path, const svn_dirent_t *dirent, const svn_lock_t *lock, const char *abs_path, apr_pool_t *pool) { return SVN_NO_ERROR; }
return SVN_NO_ERROR;
}
static svn_error_t *my_simple_prompt_callback(svn_auth_cred_simple_t ** cred, void *baton, const char *realm, const char *username, svn_boolean_t may_save, apr_pool_t * pool) { static svn_error_t *my_simple_prompt_callback(svn_auth_cred_simple_t **cred, void *baton, const char *realm, const char *username, svn_boolean_t may_save, apr_pool_t *pool) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
svn_auth_cred_simple_t *ret = apr_pcalloc(pool, sizeof(*ret)); svn_auth_cred_simple_t *ret = apr_pcalloc(pool, sizeof(*ret));
@ -50,11 +56,13 @@ static svn_error_t *my_simple_prompt_callback(svn_auth_cred_simple_t ** cred, vo
return SVN_NO_ERROR; return SVN_NO_ERROR;
} }
int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
//int32_t ipv6 = 0; // int32_t ipv6 = 0;
char URL[1024]; char URL[1024];
char URLBRANCH[256]; char URLBRANCH[256];
#if SVN_VER_MINOR > 7
const char *canonical; const char *canonical;
#endif
apr_pool_t *pool; apr_pool_t *pool;
svn_error_t *err; svn_error_t *err;
svn_opt_revision_t revision; svn_opt_revision_t revision;
@ -71,31 +79,37 @@ int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char
if (svn_cmdline_init("hydra", stderr) != EXIT_SUCCESS) if (svn_cmdline_init("hydra", stderr) != EXIT_SUCCESS)
return 4; return 4;
//if (ip[0] == 16) // if (ip[0] == 16)
// ipv6 = 1; // ipv6 = 1;
pool = svn_pool_create(NULL); pool = svn_pool_create(NULL);
err = svn_config_ensure(NULL, pool); err = svn_config_ensure(NULL, pool);
if (err) { if (err) {
svn_pool_destroy(pool);
svn_handle_error2(err, stderr, FALSE, "hydra: "); svn_handle_error2(err, stderr, FALSE, "hydra: ");
return 4; return 4;
} }
//if ((err = svn_client_create_context(&ctx, pool))) { #if SVN_VER_MINOR > 7
if ((err = svn_client_create_context2(&ctx, NULL, pool))) { if ((err = svn_client_create_context2(&ctx, NULL, pool))) {
#else
if ((err = svn_client_create_context(&ctx, pool))) {
#endif
svn_pool_destroy(pool);
svn_handle_error2(err, stderr, FALSE, "hydra: "); svn_handle_error2(err, stderr, FALSE, "hydra: ");
return 4; return 4;
} }
if ((err = svn_config_get_config(&(ctx->config), NULL, pool))) { if ((err = svn_config_get_config(&(ctx->config), NULL, pool))) {
svn_pool_destroy(pool);
svn_handle_error2(err, stderr, FALSE, "hydra: "); svn_handle_error2(err, stderr, FALSE, "hydra: ");
return 4; return 4;
} }
providers = apr_array_make(pool, 1, sizeof(svn_auth_provider_object_t *)); providers = apr_array_make(pool, 1, sizeof(svn_auth_provider_object_t *));
svn_auth_get_simple_prompt_provider(&provider, my_simple_prompt_callback, NULL, /* baton */ svn_auth_get_simple_prompt_provider(&provider, my_simple_prompt_callback, NULL, /* baton */
0, pool); 0, pool);
APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
@ -105,24 +119,29 @@ int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char
revision.kind = svn_opt_revision_head; revision.kind = svn_opt_revision_head;
snprintf(URL, sizeof(URL), "svn://%s:%d/%s", hydra_address2string_beautiful(ip), port, URLBRANCH); snprintf(URL, sizeof(URL), "svn://%s:%d/%s", hydra_address2string_beautiful(ip), port, URLBRANCH);
dirents = SVN_DIRENT_KIND; dirents = SVN_DIRENT_KIND;
#if SVN_VER_MINOR > 9
canonical = svn_uri_canonicalize(URL, pool); canonical = svn_uri_canonicalize(URL, pool);
//err = svn_client_list2(canonical, &revision, &revision, svn_depth_unknown, dirents, FALSE, print_dirdummy, NULL, ctx, pool); err = svn_client_list4(canonical, &revision, &revision, NULL, svn_depth_unknown, dirents, FALSE, FALSE, (svn_client_list_func2_t)print_dirdummy, NULL, ctx, pool);
err = svn_client_list3(canonical, &revision, &revision, svn_depth_unknown, dirents, FALSE, FALSE, (svn_client_list_func2_t) print_dirdummy, NULL, ctx, pool); #elif SVN_VER_MINOR > 7
canonical = svn_uri_canonicalize(URL, pool);
err = svn_client_list3(canonical, &revision, &revision, svn_depth_unknown, dirents, FALSE, FALSE, (svn_client_list_func2_t)print_dirdummy, NULL, ctx, pool);
#else
err = svn_client_list2(URL, &revision, &revision, svn_depth_unknown, dirents, FALSE, print_dirdummy, NULL, ctx, pool);
#endif
svn_pool_clear(pool);
svn_pool_destroy(pool); svn_pool_destroy(pool);
if (err) { if (err) {
if (debug || (verbose && (err->apr_err != 170001 && err->apr_err != 170013))) if (debug || (verbose && (err->apr_err != 170001 && err->apr_err != 170013)))
hydra_report(stderr, "[ERROR] Access refused (error code %d) , message: %s\n", err->apr_err, err->message); hydra_report(stderr, "[ERROR] Access refused (error code %d) , message: %s\n", err->apr_err, err->message);
//Username not found 170001 ": Username not found" // Username not found 170001 ": Username not found"
//Password incorrect 170001 ": Password incorrect" // Password incorrect 170001 ": Password incorrect"
if (err->apr_err != 170001 && err->apr_err != 170013) { if (err->apr_err != 170001 && err->apr_err != 170013) {
return 4; //error return 4; // error
} else { } else {
if (strstr(err->message, "Username not found")) { if (strstr(err->message, "Username not found")) {
//if (verbose) // if (verbose)
//printf("[INFO] user %s does not exist, skipping\n", login); // printf("[INFO] user %s does not exist, skipping\n", login);
hydra_completed_pair_skip(); hydra_completed_pair_skip();
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
@ -142,7 +161,7 @@ int32_t start_svn(int32_t s, char *ip, int32_t port, unsigned char options, char
return 3; return 3;
} }
void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_SVN, mysslport = PORT_SVN_SSL; int32_t myport = PORT_SVN, mysslport = PORT_SVN_SSL;
@ -153,11 +172,11 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -171,7 +190,7 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -179,6 +198,8 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
break; break;
case 2: case 2:
next_run = start_svn(sock, ip, port, options, miscptr, fp); next_run = start_svn(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break; break;
case 3: case 3:
if (sock >= 0) if (sock >= 0)
@ -187,7 +208,8 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
default: default:
if (!verbose) if (!verbose)
hydra_report(stderr, "[ERROR] Caught unknown return code, try verbose option for more details\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, try verbose "
"option for more details\n");
hydra_child_exit(0); hydra_child_exit(0);
} }
run = next_run; run = next_run;
@ -196,20 +218,29 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
#endif #endif
int32_t service_svn_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_svn_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
#ifdef LIBSVN
if (verbose)
hydra_report(stderr, "[VERBOSE] detected subversion library v%d.%d\n", SVN_VER_MAJOR, SVN_VER_MINOR);
if (SVN_VER_MAJOR != 1 && SVN_VER_MINOR >= 5) {
hydra_report(stderr, "[ERROR] unsupported subversion library v%d.%d, exiting!\n", SVN_VER_MAJOR, SVN_VER_MINOR);
return -1;
}
#endif
return 0; return 0;
} }
void usage_svn(const char* service) { void usage_svn(const char *service) {
printf("Module svn is optionally taking the repository name to attack, default is \"trunk\"\n\n"); printf("Module svn is optionally taking the repository name to attack, "
"default is \"trunk\"\n\n");
} }

View file

@ -36,9 +36,8 @@ struct team_speak {
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec); extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf;
int32_t start_teamspeak(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_teamspeak(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass; char *login, *pass;
char buf[100]; char buf[100];
@ -54,21 +53,21 @@ int32_t start_teamspeak(int32_t s, char *ip, int32_t port, unsigned char options
memcpy(&teamspeak.header, "\xf4\xbe\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", 16); memcpy(&teamspeak.header, "\xf4\xbe\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", 16);
teamspeak.clientlen = 9; teamspeak.clientlen = 9;
strcpy((char *) &teamspeak.client, "TeamSpeak"); strcpy((char *)&teamspeak.client, "TeamSpeak");
teamspeak.oslen = 11; teamspeak.oslen = 11;
strcpy((char *) &teamspeak.os, "Linux 2.6.9"); strcpy((char *)&teamspeak.os, "Linux 2.6.9");
memcpy(&teamspeak.misc, "\x02\x00\x00\x00\x20\x00\x3c\x00\x01\x02", 10); memcpy(&teamspeak.misc, "\x02\x00\x00\x00\x20\x00\x3c\x00\x01\x02", 10);
teamspeak.userlen = strlen(login); teamspeak.userlen = strlen(login);
strncpy((char *) &teamspeak.user, login, 29); strncpy((char *)&teamspeak.user, login, 29);
teamspeak.passlen = strlen(pass); teamspeak.passlen = strlen(pass);
strncpy((char *) &teamspeak.pass, pass, 29); strncpy((char *)&teamspeak.pass, pass, 29);
teamspeak.loginlen = 0; teamspeak.loginlen = 0;
strcpy((char *) &teamspeak.login, ""); strcpy((char *)&teamspeak.login, "");
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
teamspeak.crc = crc32(0L, (const Bytef *)&teamspeak, sizeof(struct team_speak)); teamspeak.crc = crc32(0L, (const Bytef *)&teamspeak, sizeof(struct team_speak));
@ -76,22 +75,22 @@ int32_t start_teamspeak(int32_t s, char *ip, int32_t port, unsigned char options
teamspeak.crc = crc32(&teamspeak, sizeof(struct team_speak)); teamspeak.crc = crc32(&teamspeak, sizeof(struct team_speak));
#endif #endif
if (hydra_send(s, (char *) &teamspeak, sizeof(struct team_speak), 0) < 0) { if (hydra_send(s, (char *)&teamspeak, sizeof(struct team_speak), 0) < 0) {
return 3; return 3;
} }
if (hydra_data_ready_timed(s, 5, 0) > 0) { if (hydra_data_ready_timed(s, 5, 0) > 0) {
hydra_recv(s, (char *) buf, sizeof(buf)); hydra_recv(s, (char *)buf, sizeof(buf));
if (buf[0x58] == 1) { if (buf[0x58] == 1) {
hydra_report_found_host(port, ip, "teamspeak", fp); hydra_report_found_host(port, ip, "teamspeak", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
} }
if (buf[0x4B] != 0) { if (buf[0x4B] != 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
} else { } else {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
@ -102,7 +101,7 @@ int32_t start_teamspeak(int32_t s, char *ip, int32_t port, unsigned char options
return 1; return 1;
} }
void service_teamspeak(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_teamspeak(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_TEAMSPEAK; int32_t myport = PORT_TEAMSPEAK;
@ -113,23 +112,23 @@ void service_teamspeak(char *ip, int32_t sp, unsigned char options, char *miscpt
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
// if (sock >= 0) // if (sock >= 0)
// sock = hydra_disconnect(sock); // sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if (sock < 0) { if (sock < 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
sock = hydra_connect_udp(ip, myport); sock = hydra_connect_udp(ip, myport);
port = myport; port = myport;
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
} }
next_run = start_teamspeak(sock, ip, port, options, miscptr, fp); next_run = start_teamspeak(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(2); hydra_child_exit(2);
@ -142,13 +141,13 @@ void service_teamspeak(char *ip, int32_t sp, unsigned char options, char *miscpt
} }
} }
int32_t service_teamspeak_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_teamspeak_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -5,7 +5,7 @@ extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t no_line_mode; int32_t no_line_mode;
int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *login, *pass, buffer[300]; char *login, *pass, buffer[300];
int32_t i = 0; int32_t i = 0;
@ -36,7 +36,7 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c
if ((buf = hydra_receive_line(s)) == NULL) if ((buf = hydra_receive_line(s)) == NULL)
return 1; return 1;
if (index(buf, '/') != NULL || index(buf, '>') != NULL || index(buf, '%') != NULL || index(buf, '$') != NULL || index(buf, '#') != NULL) { if (strchr(buf, '/') != NULL || strchr(buf, '>') != NULL || strchr(buf, '%') != NULL || strchr(buf, '$') != NULL || strchr(buf, '#') != NULL) {
hydra_report_found_host(port, ip, "telnet", fp); hydra_report_found_host(port, ip, "telnet", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
free(buf); free(buf);
@ -44,7 +44,7 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c
return 3; return 3;
return 1; return 1;
} }
(void) make_to_lower(buf); (void)make_to_lower(buf);
if (hydra_strcasestr(buf, "asswor") != NULL || hydra_strcasestr(buf, "asscode") != NULL || hydra_strcasestr(buf, "ennwort") != NULL) if (hydra_strcasestr(buf, "asswor") != NULL || hydra_strcasestr(buf, "asscode") != NULL || hydra_strcasestr(buf, "ennwort") != NULL)
i = 1; i = 1;
@ -75,19 +75,41 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c
} }
/*win7 answering with do terminal type = 0xfd 0x18 */ /*win7 answering with do terminal type = 0xfd 0x18 */
while ((buf = hydra_receive_line(s)) != NULL && make_to_lower(buf) && (strstr(buf, "login:") == NULL || strstr(buf, "last login:") != NULL) && strstr(buf, "sername:") == NULL) { while ((buf = hydra_receive_line(s)) != NULL && make_to_lower(buf) && (strstr(buf, "password:") == NULL || strstr(buf, "login:") == NULL || strstr(buf, "last login:") != NULL) && strstr(buf, "sername:") == NULL) {
if ((miscptr != NULL && strstr(buf, miscptr) != NULL) || (miscptr == NULL && if ((miscptr != NULL && strstr(buf, miscptr) != NULL) || (miscptr == NULL && strstr(buf, "invalid") == NULL && strstr(buf, "incorrect") == NULL && strstr(buf, "bad ") == NULL && (strchr(buf, '/') != NULL || strchr(buf, '>') != NULL || strchr(buf, '$') != NULL || strchr(buf, '#') != NULL || strchr(buf, '%') != NULL || ((buf[1] == '\xfd') && (buf[2] == '\x18'))))) {
strstr(buf, "invalid") == NULL && strstr(buf, "failed") == NULL && strstr(buf, "bad ") == NULL &&
(index(buf, '/') != NULL || index(buf, '>') != NULL || index(buf, '$') != NULL || index(buf, '#') != NULL ||
index(buf, '%') != NULL || ((buf[1] == '\xfd') && (buf[2] == '\x18'))))) {
hydra_report_found_host(port, ip, "telnet", fp); hydra_report_found_host(port, ip, "telnet", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
free(buf); free(buf);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3; return 3;
return 1; return 1;
} } else if (buf && strstr(buf, "assword:")) {
free(buf); hydra_completed_pair();
// printf("password prompt\n");
free(buf);
if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty;
sprintf(buffer, "%s\r", pass);
if (no_line_mode) {
for (i = 0; i < strlen(buffer); i++) {
if (strcmp(&buffer[i], "\r") == 0) {
send(s, "\r\0", 2, 0);
} else {
send(s, &buffer[i], 1, 0);
}
usleepn(20);
}
} else {
if (hydra_send(s, buffer, strlen(buffer) + 1, 0) < 0) {
return 1;
}
}
} else if (buf && strstr(buf, "login:")) {
free(buf);
hydra_completed_pair();
return 2;
} else
free(buf);
} }
hydra_completed_pair(); hydra_completed_pair();
@ -96,7 +118,7 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c
return 2; return 2;
} }
void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1, fck; int32_t run = 1, next_run = 1, sock = -1, fck;
int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL; int32_t myport = PORT_TELNET, mysslport = PORT_TELNET_SSL;
@ -110,10 +132,10 @@ void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr,
int32_t old_waittime = waittime; int32_t old_waittime = waittime;
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
no_line_mode = 0; no_line_mode = 0;
first = 0; first = 0;
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -128,13 +150,13 @@ void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr,
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
if ((buf = hydra_receive_line(sock)) == NULL) { /* check the first line */ if ((buf = hydra_receive_line(sock)) == NULL) { /* check the first line */
hydra_report(stderr, "[ERROR] Not a TELNET protocol or service shutdown\n"); hydra_report(stderr, "[ERROR] Not a TELNET protocol or service shutdown\n");
hydra_child_exit(2); hydra_child_exit(2);
// hydra_child_exit(2); // hydra_child_exit(2);
} }
if (hydra_strcasestr(buf, "ress ENTER") != NULL) { if (hydra_strcasestr(buf, "ress ENTER") != NULL) {
hydra_send(sock, "\r\n", 2, 0); hydra_send(sock, "\r\n", 2, 0);
@ -150,7 +172,7 @@ void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr,
hydra_report(stdout, "DEBUG: waittime set to %d\n", waittime); hydra_report(stdout, "DEBUG: waittime set to %d\n", waittime);
} }
do { do {
unsigned char *buf2 = (unsigned char *) buf; unsigned char *buf2 = (unsigned char *)buf;
while (*buf2 == IAC) { while (*buf2 == IAC) {
if (first == 0) { if (first == 0) {
@ -175,23 +197,23 @@ void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr,
buf2 = buf2 + 3; buf2 = buf2 + 3;
} }
if (buf2 != (unsigned char *) buf) { if (buf2 != (unsigned char *)buf) {
free(buf); free(buf);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
} else { } else {
buf[0] = 0; buf[0] = 0;
} }
if (buf != NULL && buf[0] != 0 && (unsigned char) buf[0] != IAC) if (buf != NULL && buf[0] != 0 && (unsigned char)buf[0] != IAC)
make_to_lower(buf); make_to_lower(buf);
} while (buf != NULL && (unsigned char) buf[0] == IAC && hydra_strcasestr(buf, "ogin:") == NULL && hydra_strcasestr(buf, "sername:") == NULL); } while (buf != NULL && (unsigned char)buf[0] == IAC && hydra_strcasestr(buf, "ogin:") == NULL && hydra_strcasestr(buf, "sername:") == NULL);
free(buf); free(buf);
waittime = old_waittime; waittime = old_waittime;
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_telnet(sock, ip, port, options, miscptr, fp); next_run = start_telnet(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -204,13 +226,13 @@ void service_telnet(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
} }
int32_t service_telnet_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_telnet_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here
@ -218,7 +240,9 @@ int32_t service_telnet_init(char *ip, int32_t sp, unsigned char options, char *m
return 0; return 0;
} }
void usage_telnet(const char* service) { void usage_telnet(const char *service) {
printf("Module telnet is optionally taking the string which is displayed after\n" printf("Module telnet is optionally taking the string which is displayed after\n"
"a successful login (case insensitive), use if the default in the telnet\n" "module produces too many false positives\n\n"); "a successful login (case insensitive), use if the default in the "
"telnet\n"
"module produces too many false positives\n\n");
} }

View file

@ -2,30 +2,23 @@
#ifndef _WIN32 #ifndef _WIN32
#include <time.h> #include <time.h>
int32_t sleepn(time_t seconds) int32_t sleepn(time_t seconds) {
{ struct timespec ts;
struct timespec ts; ts.tv_sec = seconds;
ts.tv_sec = seconds; ts.tv_nsec = 0;
ts.tv_nsec = 0; return nanosleep(&ts, NULL);
return nanosleep(&ts, NULL);
} }
int32_t usleepn(uint64_t milisec) { int32_t usleepn(uint64_t milisec) {
struct timespec ts; struct timespec ts;
ts.tv_sec = milisec / 1000; ts.tv_sec = milisec / 1000;
ts.tv_nsec = (milisec % 1000) * 1000000L; ts.tv_nsec = (milisec % 1000) * 1000000L;
return nanosleep(&ts, NULL); return nanosleep(&ts, NULL);
} }
#else #else
#include <windows.h> #include <windows.h>
int32_t sleepn(uint32_t seconds) int32_t sleepn(uint32_t seconds) { return SleepEx(milisec * 1000, TRUE); }
{
return SleepEx(milisec*1000,TRUE);
}
int32_t usleepn(uint32_t milisec) int32_t usleepn(uint32_t milisec) { return SleepEx(milisec, TRUE); }
{
return SleepEx(milisec,TRUE);
}
#endif #endif

View file

@ -1,16 +1,15 @@
//This plugin was written by david@ // This plugin was written by david@
// //
//This plugin is written for VMware Authentication Daemon // This plugin is written for VMware Authentication Daemon
// //
#include "hydra-mod.h" #include "hydra-mod.h"
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; char *buf;
int32_t start_vmauthd(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_vmauthd(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = "\"\""; char *empty = "\"\"";
char *login, *pass, buffer[300]; char *login, *pass, buffer[300];
@ -45,9 +44,9 @@ int32_t start_vmauthd(int32_t s, char *ip, int32_t port, unsigned char options,
if ((buf = hydra_receive_line(s)) == NULL) if ((buf = hydra_receive_line(s)) == NULL)
return (1); return (1);
//fprintf(stderr, "%s\n", buf); // fprintf(stderr, "%s\n", buf);
//230 User test logged in. // 230 User test logged in.
//530 Login incorrect. // 530 Login incorrect.
if (strncmp(buf, "230 ", 4) == 0) { if (strncmp(buf, "230 ", 4) == 0) {
hydra_report_found_host(port, ip, "vmauthd", fp); hydra_report_found_host(port, ip, "vmauthd", fp);
@ -65,7 +64,7 @@ int32_t start_vmauthd(int32_t s, char *ip, int32_t port, unsigned char options,
return 2; return 2;
} }
void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_VMAUTHD, mysslport = PORT_VMAUTHD_SSL; int32_t myport = PORT_VMAUTHD, mysslport = PORT_VMAUTHD_SSL;
@ -74,10 +73,10 @@ void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr,
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
// usleepn(300); // usleepn(300);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
if (port != 0) if (port != 0)
myport = port; myport = port;
@ -92,14 +91,15 @@ void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr,
if (sock < 0) { if (sock < 0) {
if (verbose || debug) if (verbose || debug)
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
//fprintf(stderr, "%s\n",buf); // fprintf(stderr, "%s\n",buf);
//220 VMware Authentication Daemon Version 1.00 // 220 VMware Authentication Daemon Version 1.00
//220 VMware Authentication Daemon Version 1.10: SSL Required // 220 VMware Authentication Daemon Version 1.10: SSL Required
//220 VMware Authentication Daemon Version 1.10: SSL Required, ServerDaemonProtocol:SOAP, MKSDisplayProtocol:VNC , // 220 VMware Authentication Daemon Version 1.10: SSL Required,
// ServerDaemonProtocol:SOAP, MKSDisplayProtocol:VNC ,
if (buf == NULL || strstr(buf, "220 VMware Authentication Daemon Version ") == NULL) { if (buf == NULL || strstr(buf, "220 VMware Authentication Daemon Version ") == NULL) {
/* check the first line */ /* check the first line */
@ -108,14 +108,17 @@ void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr,
hydra_child_exit(2); hydra_child_exit(2);
} }
if ((strstr(buf, "Version 1.00") == NULL) && (strstr(buf, "Version 1.10") == NULL)) { if ((strstr(buf, "Version 1.00") == NULL) && (strstr(buf, "Version 1.10") == NULL)) {
hydra_report(stderr, "[ERROR] this vmware authd protocol is not supported, please report: %s\n", buf); hydra_report(stderr,
"[ERROR] this vmware authd protocol is not supported, "
"please report: %s\n",
buf);
free(buf); free(buf);
hydra_child_exit(2); hydra_child_exit(2);
} }
//by default this service is waiting for ssl connections // by default this service is waiting for ssl connections
if (strstr(buf, "SSL Required") != NULL) { if (strstr(buf, "SSL Required") != NULL) {
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
//reconnecting using SSL // reconnecting using SSL
if (hydra_connect_to_ssl(sock, hostname) == -1) { if (hydra_connect_to_ssl(sock, hostname) == -1) {
free(buf); free(buf);
hydra_report(stderr, "[ERROR] Can't use SSL\n"); hydra_report(stderr, "[ERROR] Can't use SSL\n");
@ -127,13 +130,14 @@ void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr,
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_vmauthd(sock, ip, port, options, miscptr, fp); next_run = start_vmauthd(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
break;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(2); hydra_child_exit(2);
@ -142,13 +146,13 @@ void service_vmauthd(char *ip, int32_t sp, unsigned char options, char *miscptr,
} }
} }
int32_t service_vmauthd_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_vmauthd_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -5,21 +5,21 @@
* *
*/ */
#include "hydra-mod.h"
#include "d3des.h" #include "d3des.h"
#include "hydra-mod.h"
#define CHALLENGESIZE 16 #define CHALLENGESIZE 16
//for RFB 003.003 & 003.005 // for RFB 003.003 & 003.005
#define RFB33 1 #define RFB33 1
//for RFB 3.7 and onwards // for RFB 3.7 and onwards
#define RFB37 2 #define RFB37 2
int32_t vnc_client_version = RFB33; int32_t vnc_client_version = RFB33;
int32_t failed_auth = 0; int32_t failed_auth = 0;
extern char *HYDRA_EXIT; extern char *HYDRA_EXIT;
char *buf; static char *buf;
/* /*
* Encrypt CHALLENGESIZE bytes in memory using a password. * Encrypt CHALLENGESIZE bytes in memory using a password.
@ -44,7 +44,7 @@ void vncEncryptBytes(unsigned char *bytes, char *passwd) {
} }
} }
int32_t start_vnc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) { int32_t start_vnc(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
char *empty = ""; char *empty = "";
char *pass; char *pass;
unsigned char buf2[CHALLENGESIZE + 4]; unsigned char buf2[CHALLENGESIZE + 4];
@ -57,26 +57,27 @@ int32_t start_vnc(int32_t s, char *ip, int32_t port, unsigned char options, char
if (vnc_client_version == RFB37) { if (vnc_client_version == RFB37) {
int32_t i; int32_t i;
//fprintf(stderr,"number of security types supported: %d\n", buf2[0]); // fprintf(stderr,"number of security types supported: %d\n", buf2[0]);
if (buf2[0] == 0 || buf2[0] > CHALLENGESIZE + 4) { if (buf2[0] == 0 || buf2[0] > CHALLENGESIZE + 4) {
hydra_report(stderr, "[ERROR] VNC server connection failed\n"); hydra_report(stderr, "[ERROR] VNC server connection failed\n");
hydra_child_exit(0); hydra_child_exit(0);
} }
for (i = 1; i <= buf2[0]; i++) { for (i = 1; i <= buf2[0]; i++) {
//fprintf(stderr,"sec type %u\n",buf2[i]); // fprintf(stderr,"sec type %u\n",buf2[i]);
//check if weak security types are available // check if weak security types are available
if (buf2[i] <= 0x2) { if (buf2[i] <= 0x2) {
buf2[3] = buf2[i]; buf2[3] = buf2[i];
break; break;
} }
} }
} }
//supported security type // supported security type
switch (buf2[3]) { switch (buf2[3]) {
case 0x0: case 0x0:
hydra_report(stderr, "[ERROR] VNC server told us to quit %c\n", buf[3]); hydra_report(stderr, "[ERROR] VNC server told us to quit %c\n", buf2[3]);
hydra_child_exit(0); hydra_child_exit(0);
break;
case 0x1: case 0x1:
hydra_report(fp, "VNC server does not require authentication.\n"); hydra_report(fp, "VNC server does not require authentication.\n");
if (fp != stdout) if (fp != stdout)
@ -84,35 +85,36 @@ int32_t start_vnc(int32_t s, char *ip, int32_t port, unsigned char options, char
hydra_report_found_host(port, ip, "vnc", fp); hydra_report_found_host(port, ip, "vnc", fp);
hydra_completed_pair_found(); hydra_completed_pair_found();
hydra_child_exit(2); hydra_child_exit(2);
break;
case 0x2: case 0x2:
//VNC security type supported is the only type supported for now // VNC security type supported is the only type supported for now
if (vnc_client_version == RFB37) { if (vnc_client_version == RFB37) {
sprintf(buf, "%c", 0x2); sprintf(buf, "%c", 0x2);
if (hydra_send(s, buf, strlen(buf), 0) < 0) { if (hydra_send(s, buf, strlen(buf), 0) < 0) {
return 1; return 1;
} }
//get authentication challenge from server // get authentication challenge from server
if (recv(s, buf2, CHALLENGESIZE, 0) == -1) if (recv(s, buf2, CHALLENGESIZE, 0) == -1)
return 1; return 1;
//send response // send response
vncEncryptBytes(buf2, pass); vncEncryptBytes(buf2, pass);
if (hydra_send(s, (char *) buf2, CHALLENGESIZE, 0) < 0) { if (hydra_send(s, (char *)buf2, CHALLENGESIZE, 0) < 0) {
return 1; return 1;
} }
} else { } else {
//in old proto, challenge is following the security type // in old proto, challenge is following the security type
vncEncryptBytes((unsigned char *) buf2 + 4, pass); vncEncryptBytes((unsigned char *)buf2 + 4, pass);
if (hydra_send(s, (char *) buf2 + 4, CHALLENGESIZE, 0) < 0) { if (hydra_send(s, (char *)buf2 + 4, CHALLENGESIZE, 0) < 0) {
return 1; return 1;
} }
} }
break; break;
default: default:
hydra_report(stderr, "[ERROR] unknown VNC security type\n"); hydra_report(stderr, "[ERROR] unknown VNC security type 0x%x\n", buf2[3]);
hydra_child_exit(2); hydra_child_exit(2);
} }
//check security result value // check security result value
recv(s, buf, 4, 0); recv(s, buf, 4, 0);
if (buf == NULL) if (buf == NULL)
return 1; return 1;
@ -140,10 +142,10 @@ int32_t start_vnc(int32_t s, char *ip, int32_t port, unsigned char options, char
return 1; return 1;
} }
return 1; /* never reached */ return 1; /* never reached */
} }
void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
int32_t run = 1, next_run = 1, sock = -1; int32_t run = 1, next_run = 1, sock = -1;
int32_t myport = PORT_VNC, mysslport = PORT_VNC_SSL; int32_t myport = PORT_VNC, mysslport = PORT_VNC_SSL;
@ -152,7 +154,7 @@ void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
return; return;
while (1) { while (1) {
switch (run) { switch (run) {
case 1: /* connect and service init function */ case 1: /* connect and service init function */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
if ((options & OPTION_SSL) == 0) { if ((options & OPTION_SSL) == 0) {
@ -167,26 +169,28 @@ void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
port = mysslport; port = mysslport;
} }
if (sock < 0) { if (sock < 0) {
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t) getpid()); hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int32_t)getpid());
hydra_child_exit(1); hydra_child_exit(1);
} }
usleepn(300); usleepn(300);
buf = hydra_receive_line(sock); buf = hydra_receive_line(sock);
if (buf == NULL || (strncmp(buf, "RFB", 3) != 0)) { /* check the first line */ if (buf == NULL || (strncmp(buf, "RFB", 3) != 0)) { /* check the first line */
hydra_report(stderr, "[ERROR] Not a VNC protocol or service shutdown: %s\n", buf); hydra_report(stderr, "[ERROR] Not a VNC protocol or service shutdown: %s\n", buf);
hydra_child_exit(2); hydra_child_exit(2);
} }
if (strstr(buf, " security failures") != NULL) { /* check the first line */ if (strstr(buf, " security failures") != NULL) { /* check the first line */
/* /*
VNC has a 'blacklisting' scheme that blocks an IP address after five unsuccessful connection attempts. VNC has a 'blacklisting' scheme that blocks an IP address after five
The IP address is initially blocked for ten seconds, unsuccessful connection attempts. The IP address is initially blocked
but this doubles for each unsuccessful attempt thereafter. for ten seconds, but this doubles for each unsuccessful attempt
A successful connection from an IP address resets the blacklist timeout. thereafter. A successful connection from an IP address resets the
This is built in to VNC Server and does not rely on operating system support. blacklist timeout. This is built in to VNC Server and does not rely
on operating system support.
*/ */
failed_auth++; failed_auth++;
hydra_report(stderr, "VNC server reported too many authentication failures, have to wait some seconds ...\n"); hydra_report(stderr, "VNC server reported too many authentication "
"failures, have to wait some seconds ...\n");
sleep(12 * failed_auth); sleep(12 * failed_auth);
free(buf); free(buf);
next_run = 1; next_run = 1;
@ -194,13 +198,14 @@ void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
if (verbose) if (verbose)
hydra_report(stderr, "[VERBOSE] Server banner is %s\n", buf); hydra_report(stderr, "[VERBOSE] Server banner is %s\n", buf);
if (((strstr(buf, "RFB 004.001") != NULL) || (strstr(buf, "RFB 003.007") != NULL) || (strstr(buf, "RFB 003.008") != NULL))) { if (((strstr(buf, "RFB 005.000") != NULL) || (strstr(buf, "RFB 004") != NULL) || (strstr(buf, "RFB 003.007") != NULL) || (strstr(buf, "RFB 003.008") != NULL))) {
//using proto version 003.008 to talk to server 004.001 same for 3.7 and 3.8 // using proto version 003.007 to talk to server 005.xxx and 004.xxx
// same for 3.7 and 3.8
vnc_client_version = RFB37; vnc_client_version = RFB37;
free(buf); free(buf);
buf = strdup("RFB 003.007\n"); buf = strdup("RFB 003.007\n");
} else { } else {
//for RFB 3.3 and fake 3.5 // for RFB 3.3 and fake 3.5
vnc_client_version = RFB33; vnc_client_version = RFB33;
free(buf); free(buf);
buf = strdup("RFB 003.003\n"); buf = strdup("RFB 003.003\n");
@ -208,10 +213,10 @@ void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
hydra_send(sock, buf, strlen(buf), 0); hydra_send(sock, buf, strlen(buf), 0);
next_run = 2; next_run = 2;
break; break;
case 2: /* run the cracking function */ case 2: /* run the cracking function */
next_run = start_vnc(sock, ip, port, options, miscptr, fp); next_run = start_vnc(sock, ip, port, options, miscptr, fp);
break; break;
case 3: /* clean exit */ case 3: /* clean exit */
if (sock >= 0) if (sock >= 0)
sock = hydra_disconnect(sock); sock = hydra_disconnect(sock);
hydra_child_exit(0); hydra_child_exit(0);
@ -229,13 +234,13 @@ void service_vnc(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
} }
} }
int32_t service_vnc_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) { int32_t service_vnc_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
// called before the childrens are forked off, so this is the function // called before the childrens are forked off, so this is the function
// which should be filled if initial connections and service setup has to be // which should be filled if initial connections and service setup has to be
// performed once only. // performed once only.
// //
// fill if needed. // fill if needed.
// //
// return codes: // return codes:
// 0 all OK // 0 all OK
// -1 error, hydra will exit, so print a good error message here // -1 error, hydra will exit, so print a good error message here

View file

@ -33,10 +33,10 @@ test -e "$pass" && passs="-P $pass"
test -e "$pass" || passs="-p $pass" test -e "$pass" || passs="-p $pass"
test -n "$port" && ports="-s $port" test -n "$port" && ports="-s $port"
test -n "$pw" && pws="-e $pw" test -n "$pw" && pws="-e $pw"
test -n "$opt" && opts="-m '$opt'" test -n "$opt" && { opts="-m $opt" ; dopts="-m '$opt'" ; }
echo The following command will be executed now: echo The following command will be executed now:
echo " hydra $users $passs -u $pws $ports $opts $targets $service" echo " hydra $users $passs -u $pws $ports $dopts $targets $service"
echo echo
read -p "Do you want to run the command now? [Y/n] " yn read -p "Do you want to run the command now? [Y/n] " yn
test "$yn" = "n" -o "$yn" = "N" && { echo Exiting. ; exit 0 ; } test "$yn" = "n" -o "$yn" = "N" && { echo Exiting. ; exit 0 ; }

Some files were not shown because too many files have changed in this diff Show more