Skip to content

Commit

Permalink
[#26] do some patches to JLU login part
Browse files Browse the repository at this point in the history
  • Loading branch information
mchome committed Jan 19, 2018
1 parent 5a25c1d commit 3af167d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test
drcom.conf
test.conf
dogcom
main
.vscode
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dogcom [![travis-ci](https://travis-ci.org/mchome/dogcom.svg "Build status")](https://travis-ci.org/mchome/dogcom) [![badge](https://img.shields.io/badge/%20built%20with-%20%E2%9D%A4-ff69b4.svg "build with love")](https://github.com/mchome/dogcom) [![version](https://img.shields.io/badge/stable%20-%20v1.6.1-4dc71f.svg "stable version")](https://github.com/mchome/dogcom/tree/v1.6.1)
# dogcom [![travis-ci](https://travis-ci.org/mchome/dogcom.svg "Build status")](https://travis-ci.org/mchome/dogcom) [![badge](https://img.shields.io/badge/%20built%20with-%20%E2%9D%A4-ff69b4.svg "build with love")](https://github.com/mchome/dogcom) [![version](https://img.shields.io/badge/stable%20-%20v1.6.2-4dc71f.svg "stable version")](https://github.com/mchome/dogcom/tree/v1.6.2)

[Drcom-generic](https://github.com/drcoms/drcom-generic) implementation in C.

Expand Down
36 changes: 29 additions & 7 deletions auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef int socklen_t;
#define BIND_PORT 61440
#define DEST_PORT 61440

int challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]) {
int dhcp_challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]) {
unsigned char challenge_packet[20], recv_packet[1024];
memset(challenge_packet, 0, 20);
challenge_packet[0] = 0x01;
Expand Down Expand Up @@ -79,13 +79,26 @@ int challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]) {
return 0;
}


int login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned char auth_information[]) {
int dhcp_login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned char auth_information[], int try_JLUversion) {
unsigned int login_packet_size;
unsigned int length_padding = 0;

int JLU_padding = 0;
if (try_JLUversion) {
printf("Start JLU mode.\n");
if (logging_flag) {
logging("Start JLU mode.\n", NULL, 0);
}
}

if (strlen(drcom_config.password) > 8) {
length_padding = strlen(drcom_config.password) - 8;
if (length_padding%2) { length_padding++; }
length_padding = strlen(drcom_config.password) - 8 + (length_padding%2);
if (try_JLUversion) {
if (strlen(drcom_config.password) != 16) {
JLU_padding = strlen(drcom_config.password) / 4;
}
length_padding = 28 + (strlen(drcom_config.password) - 8) + JLU_padding;
}
}
if (drcom_config.ror_version) {
login_packet_size = 338 + length_padding;
Expand Down Expand Up @@ -171,19 +184,22 @@ int login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned ch
unsigned char OSMinor[4] = {0x01};
unsigned char OSBuild[4] = {0x28, 0x0a};
unsigned char PlatformID[4] = {0x02};
// unsigned char ServicePack[40] = {0x33, 0x64, 0x63, 0x37, 0x39, 0x66, 0x35, 0x32, 0x31, 0x32, 0x65, 0x38, 0x31, 0x37, 0x30, 0x61, 0x63, 0x66, 0x61, 0x39, 0x65, 0x63, 0x39, 0x35, 0x66, 0x31, 0x64, 0x37, 0x34, 0x39, 0x31, 0x36, 0x35, 0x34, 0x32, 0x62, 0x65, 0x37, 0x62, 0x31};
memcpy(login_packet + 162, OSVersionInfoSize, 4);
memcpy(login_packet + 166, OSMajor, 4);
memcpy(login_packet + 170, OSMinor, 4);
memcpy(login_packet + 174, OSBuild, 4);
memcpy(login_packet + 178, PlatformID, 4);
memcpy(login_packet + 182, &drcom_config.host_os, strlen(drcom_config.host_os));
// memcpy(login_packet + 214, ServicePack, 40);
memcpy(login_packet + 310, drcom_config.AUTH_VERSION, 2);
int counter = 312;
unsigned int ror_padding = 0;
if (strlen(drcom_config.password) <= 8) {
ror_padding = 8 - strlen(drcom_config.password);
} else {
if ((strlen(drcom_config.password)-8) % 2) { ror_padding = 1; }
if (try_JLUversion) { ror_padding = JLU_padding; }
}
if (drcom_config.ror_version) {
login_packet[counter + 1] = strlen(drcom_config.password);
Expand Down Expand Up @@ -563,21 +579,26 @@ int dogcom(int try_times) {

// start dogcoming
if (strcmp(mode, "dhcp") == 0) {
int login_failed_attempts = 0;
int try_JLUversion = 0;
for(int try_counter = 0; try_counter < try_times; try_counter++) {
if(eternal_flag) {
try_counter = 0;
}
unsigned char seed[4];
unsigned char auth_information[16];
if (challenge(sockfd, dest_addr, seed)) {
if (dhcp_challenge(sockfd, dest_addr, seed)) {
printf("Retrying...\n");
if (logging_flag) {
logging("Retrying...", NULL, 0);
}
sleep(3);
} else {
usleep(200000); // 0.2 sec
if (!login(sockfd, dest_addr, seed, auth_information)) {
if (login_failed_attempts > 2) {
try_JLUversion = 1;
}
if (!dhcp_login(sockfd, dest_addr, seed, auth_information, try_JLUversion)) {
int keepalive_counter = 0;
int keepalive_try_counter = 0;
int first = 1;
Expand All @@ -603,6 +624,7 @@ int dogcom(int try_times) {
}
}
} else {
login_failed_attempts += 1;
printf("Retrying...\n");
if (logging_flag) {
logging("Retrying...", NULL, 0);
Expand Down
4 changes: 2 additions & 2 deletions auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ enum {
MUST_USE_DHCP = 0x17
};

int challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]);
int login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned char auth_information[]);
int dhcp_challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]);
int dhcp_login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned char auth_information[], int try_JLUversion);
int pppoe_challenge(int sockfd, struct sockaddr_in addr, int *pppoe_counter, unsigned char seed[], unsigned char sip[], int *encrypt_mode);
int pppoe_login(int sockfd, struct sockaddr_in addr, int *pppoe_counter, unsigned char seed[], unsigned char sip[], int *first, int *encrypt_mode, int *encrypt_type);
int dogcom(int try_times);
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "libs/common.h"
#endif

#define VERSION "1.6.1"
#define VERSION "1.6.2"

void print_help(int exval);
int try_smart_eaplogin(void);
Expand Down

0 comments on commit 3af167d

Please sign in to comment.