}
/**
+ * Generate Unique Hardware Identifier (CLIENT_HARDWARE_ID).\n
+ * @param license license module
+ */
+
+void license_generate_hwid(rdpLicense* license)
+{
+ CryptoMd5 md5;
+ uint8* mac_address;
+
+ memset(license->hwid, 0, 20);
+ mac_address = license->rdp->transport->tcp->mac_address;
+
+ md5 = crypto_md5_init();
+ crypto_md5_update(md5, mac_address, 6);
+ crypto_md5_final(md5, &license->hwid[4]);
+}
+
+/**
* Read Product Information (PRODUCT_INFO).\n
* @msdn{cc241915}
* @param s stream
{
stream_write_uint8(s, 0); /* Client Operating System Version */
stream_write_uint8(s, 0); /* Independent Software Vendor (ISV) */
- stream_write_uint16(s, 0x0201); /* Client Software Build */
+ stream_write_uint16(s, 0); /* Client Software Build */
}
/**
void license_write_platform_challenge_response_packet(rdpLicense* license, STREAM* s)
{
+ license_generate_hwid(license);
+
/* EncryptedPlatformChallengeResponse */
/* EncryptedHWID */
typedef struct rdp_license rdpLicense;
#include "rdp.h"
+#include "crypto.h"
#include <freerdp/freerdp.h>
#include <freerdp/utils/debug.h>
struct rdp_license
{
+ uint8 hwid[20];
struct rdp_rdp* rdp;
uint8 client_random[32];
uint8 server_random[32];
STREAM* license_send_stream_init(rdpLicense* license);
void license_generate_keys(rdpLicense* license);
+void license_generate_hwid(rdpLicense* license);
PRODUCT_INFO* license_new_product_info();
void license_free_product_info(PRODUCT_INFO* productInfo);
#include <string.h>
#include <time.h>
#include <errno.h>
-#include <sys/socket.h>
#include <netdb.h>
#include <fcntl.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include "tcp.h"
-static void tcp_get_ip_address(rdpTcp * tcp)
+void tcp_get_ip_address(rdpTcp * tcp)
{
uint8* ip;
socklen_t length;
tcp->settings->ip_address = tcp->ip_address;
}
+void tcp_get_mac_address(rdpTcp * tcp)
+{
+ uint8* mac;
+ struct ifreq if_req;
+ struct if_nameindex* ni;
+
+ ni = if_nameindex();
+ mac = tcp->mac_address;
+
+ while (ni->if_name != NULL)
+ {
+ if (strcmp(ni->if_name, "lo") != 0)
+ break;
+
+ ni++;
+ }
+
+ strncpy(if_req.ifr_name, ni->if_name, IF_NAMESIZE);
+
+ if (ioctl(tcp->sockfd, SIOCGIFHWADDR, &if_req) != 0)
+ {
+ printf("failed to obtain MAC address\n");
+ return;
+ }
+
+ memmove((void*) mac, (void*) &if_req.ifr_ifru.ifru_hwaddr.sa_data[0], 6);
+
+ /* printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); */
+}
+
boolean tcp_connect(rdpTcp* tcp, const uint8* hostname, uint16 port)
{
int status;
tcp->sockfd = sockfd;
tcp_get_ip_address(tcp);
+ tcp_get_mac_address(tcp);
return True;
}
{
int sockfd;
uint8 ip_address[32];
+ uint8 mac_address[6];
struct rdp_settings* settings;
TcpConnect connect;
TcpDisconnect disconnect;