Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

o5logon dissector overhaul. #742

Merged
merged 9 commits into from
Feb 16, 2017
Merged

Conversation

magnumripper
Copy link
Contributor

This is needed for newer versions of Oracle. It also fixes various problems in the original code but ultimately I need a fix for #741 to do it good.

@kholia
Copy link
Member

kholia commented Jul 5, 2016

@kholia
Copy link
Member

kholia commented Feb 8, 2017

@koeppea @LocutusOfBorg Ping, it would be great if you could review, and possibly merge this PR.

@LocutusOfBorg
Copy link
Contributor

I would like to see a fix for #741 before merging this one... isn''t it better?

@koeppea
Copy link
Member

koeppea commented Feb 8, 2017 via email

Copy link
Member

@koeppea koeppea left a comment

Choose a reason for hiding this comment

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

I've reviewed the pull request and have some things to be addressed.

/* PKCS#7 padding used? */
#define MAYBE 0
#define YES 1
#define NO 2
Copy link
Member

Choose a reason for hiding this comment

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

pre-processor directives and variables should be unique.
please add somwhat like EC_O5LOGON_ to the pre-processor variables.

@@ -46,6 +65,24 @@ void o5logon_init(void);

/************************************************/

#undef memrchr
#define memrchr my_memrchr
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this renaming? You shouldn't replace standard function names.
Why do you implement your own version of this standard function?

Copy link
Contributor Author

@magnumripper magnumripper Feb 8, 2017

Choose a reason for hiding this comment

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

That function is not present in eg. OSX so I implemented it. The define saves us on eg. Linux where it is present.

I don't understand cmake but I presume this could be dealt with in some more clever way (ie. use system version if present) - but this works fine as-is on Linux and OSX.

Copy link
Member

Choose a reason for hiding this comment

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

So we'd should only use it when being on a BSD or DARWIN a.k.a. MacOS operating system. The pre-processor variables are set by cmake.
I'd even recommend putting it into a "common" file like ec_utils.c that make it easier to be reused by other functions in future.
Or we could put it into a dedicated source / header file and include it into compilation processes depending on Cmake tests.

I could also help you with the Cmake part if you want.

Copy link
Member

Choose a reason for hiding this comment

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

Just checked FreeBSD. There the memrchr() function exists. MacOSX apparently is the only OS lacking memrchr() .

Copy link
Contributor Author

@magnumripper magnumripper Feb 10, 2017

Choose a reason for hiding this comment

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

Added 40979f2 which moves it to ec_utils.c and wraps with #if OS_DARWIN. Tested on OSX, "should work" on others (famous last words).

return NULL;
}

u_char *ano;
Copy link
Member

Choose a reason for hiding this comment

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

Please declare variables only at the beginning of a block, otherwise this will generate a warning.


#include <ec.h>
#include <ec_decode.h>
#include <ec_dissect.h>
#include <ec_session.h>

//#define O5DEBUG
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather recommend defining this (prefixed with EC_) with the value 0 for off and 1 for on.
to include such a block you the do #if EC_O5DEBUG instead of #ifdef ....
But this is really somewhat cosmetic and flavor.

u_char user[129];
u_char srv_addr[22];
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of srv_addr[22]? Holding the string representation of a IP address?

  1. it won't fit an IPv6 address
  2. managing IP addresses string or human representrationwise is somewhat painful.

I rather recommend using the type struct ip_addr * instead and use the ip_addr_* functions to initialize, handle and represent the IP address.

@magnumripper
Copy link
Contributor Author

magnumripper commented Feb 8, 2017

Thank you for reviewing. Requested changes are now implemented and it's also rebased onto current tree. Tested on OSX (prior to last commit it was also tested on Linux).

@magnumripper
Copy link
Contributor Author

magnumripper commented Feb 8, 2017

I would like to see a fix for #741 before merging this one... isn''t it better?

It would be beneficial for JtR and Hashcat users to have it merged right away. If/when #741 is fixed I will promptly make a PR with enhancements taking advantage of the functionality.

Copy link
Contributor

@gvanem gvanem left a comment

Choose a reason for hiding this comment

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

memrchr() should be added for OS_WINDOWS too. And IMHO, the prototype should be in put in include/ec_strings.h; similar to memmem() etc.

@koeppea
Copy link
Member

koeppea commented Feb 10, 2017

@magnumripper may I request contribution / write permissions to your fork?
I'd like to add a generic Cmake test-based approach to determine whether or not this function exist.
I can also move it to ec_strings.c as @gvanem suggested, as memrchr() is natively also defined in string.h.

@magnumripper
Copy link
Contributor Author

@koeppea you are now a collaborator.

@koeppea
Copy link
Member

koeppea commented Feb 12, 2017

Thanks.

Copy link
Member

@koeppea koeppea left a comment

Choose a reason for hiding this comment

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

I've tested the dissector with some of the PCAP files referenced.

I'm not a Oracle expert, but I'd expected some less "verbose" information. In contrast some information is only be printed with DEBUG enabled which I'd expected the other way round.

Just a comment, but I'm afraid that the messages pane gets flooded so that other potentially important information is getting lost when one or more Oracle sessions are going over the wire.

What do you think?

#if EC_O5LOGON_DEBUG
DISSECT_MSG("O5LOGON: client ver %u.%u.%u.%u.%u (PKCS)\n",
ano[0], ano[1] >> 4, ano[1] & 15 , ano[2], ano[3]);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this being worth to be print w/o DEBUG?

ntohs(PACKET->L4.dst),
conn_status->user,
conn_status->flags.c_ano == 1 ? "" : "(no ANO seen)");
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This as well?

#if EC_O5LOGON_DEBUG
DISSECT_MSG("O5LOGON: server ver %u.%u.%u.%u.%u\n", ano[0],
ano[1] >> 4, ano[1] & 15 , ano[2], ano[3]);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally had no need for either of them except while debugging / trying to understand the protocol), but I'm fine with including them w/o debug.

Copy link
Member

Choose a reason for hiding this comment

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

What do you think about the amount of information in the messages pane:

$ ettercap -Tqr ~/Downloads/ggyy-99b3ed3ed5e2a293c697784ac94ee8c6.pcap 

ettercap 0.8.2 copyright 2001-2015 Ettercap Development Team

Reading from /home/koeppea/Downloads/ggyy-99b3ed3ed5e2a293c697784ac94ee8c6.pcap
Libnet failed IPv4 initialization. Don't send IPv4 packets.
Libnet failed IPv6 initialization. Don't send IPv6 packets.
  34 plugins
  42 protocol dissectors
  57 ports monitored
20530 mac vendor fingerprint
1766 tcp OS fingerprint
2182 known services

Starting Unified sniffing...

O5LOGON: AASH@192.168.131.1:$o5logon$209C317916169AEFD4ACA354CBA5588902933CBB2C31909898F1B4A7B1B4612A423FE59958FB8E07400FC69577B7BE34*ED3BE8DDEBF2FE6FB36F
O5LOGON: AASH@192.168.131.1:$o5logon$209C317916169AEFD4ACA354CBA5588902933CBB2C31909898F1B4A7B1B4612A423FE59958FB8E07400FC69577B7BE34*ED3BE8DDEBF2FE6FB36F
O5LOGON: AASH@192.168.131.1:$o5logon$209C317916169AEFD4ACA354CBA5588902933CBB2C31909898F1B4A7B1B4612A423FE59958FB8E07400FC69577B7BE34*ED3BE8DDEBF2FE6FB36F
O5LOGON: AASH@192.168.131.1:$o5logon$209C317916169AEFD4ACA354CBA5588902933CBB2C31909898F1B4A7B1B4612A423FE59958FB8E07400FC69577B7BE34*ED3BE8DDEBF2FE6FB36F
O5LOGON: AASH@192.168.131.1:$o5logon$209C317916169AEFD4ACA354CBA5588902933CBB2C31909898F1B4A7B1B4612A423FE59958FB8E07400FC69577B7BE34*ED3BE8DDEBF2FE6FB36F
....

What can be done with this information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like I wrote below it's password hashes. I could try to reject dupes tho, but I'm not sure it's worth the effort. It shouldn't be a problem IRL.

Copy link
Member

Choose a reason for hiding this comment

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

@LocutusOfBorg what do you think about the deduplication? I have no feeling about the real world occurrence.
On the other hand, we don't have such mechanisms on other dissectors and omitting it keeps the processing lightweight.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is worth the effort...

Copy link
Contributor

Choose a reason for hiding this comment

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

somebody might want to sort and count how many people have the same password hash maybe?

@koeppea
Copy link
Member

koeppea commented Feb 13, 2017

Tested on Linux, MacOSX and FreeBSD.
@LocutusOfBorg: Good to go for me.

@magnumripper
Copy link
Contributor Author

I'm not a Oracle expert, but I'd expected some less "verbose" information.

The output is password hashes, ready to crack in JtR or Hashcat.

@magnumripper
Copy link
Contributor Author

Oh, and thanks a lot for reviewing and fixing the last issues.


#include <ec.h>
#include <ec_decode.h>
#include <ec_dissect.h>
#include <ec_session.h>
#include <ec_utils.h>

#define EC_O5LOGON_DEBUG 0
Copy link
Contributor

Choose a reason for hiding this comment

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

@koeppea what about "if not defined then define it to 0?" this way people might be able to feed this value from the environment, without having to change the source code.
it looks good to me, even if I didn't test it. Feel free to merge whenever you want :)

@LocutusOfBorg LocutusOfBorg merged commit 60aca98 into Ettercap:master Feb 16, 2017
@LocutusOfBorg
Copy link
Contributor

merged thanks you all :)

@regel
Copy link

regel commented Jun 15, 2017

@magnumripper This is awesome work. Thanks! To document the observed traffic, is it possible to summarize e.g. in a table the byte format observed on the wire versus the Oracle client and Oracle server versions actually in use?

@magnumripper
Copy link
Contributor Author

I wouldn't mind that, but unfortunately I don't have any time to invest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants