1
0
mirror of https://github.com/pumpitupdev/pumptools.git synced 2025-01-18 23:34:03 +01:00

Microdog 4.0 Emulator: Standalone

This commit is contained in:
Cube 2021-01-11 17:50:58 -08:00
parent a26830219e
commit f0040e5a1a
5 changed files with 91 additions and 3 deletions

View File

@ -174,6 +174,15 @@ $(zipdir)/pumpnet.zip: \
$(V)echo ... $@
$(V)zip -j $@ $^
################################################
# Security: Lexical sorting
$(zipdir)/security.zip: \
$(builddir)/bin/microdog40d \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
################################################
# Documentation
@ -234,6 +243,7 @@ $(builddir)/pumptools.zip: \
$(zipdir)/pro2hook.zip \
$(zipdir)/prohook.zip \
$(zipdir)/pumpnet.zip \
$(zipdir)/security.zip \
$(zipdir)/x2hook.zip \
$(zipdir)/zerohook.zip \
CHANGELOG.md \
@ -266,4 +276,4 @@ $(builddir)/pumptools-public.zip: \
################################################
package: $(builddir)/pumptools.zip $(builddir)/pumptools-public.zip
package: $(builddir)/pumptools.zip $(builddir)/pumptools-public.zip

View File

@ -1,4 +1,5 @@
add_subdirectory(hasp)
add_subdirectory(lockchip)
add_subdirectory(microdog34)
add_subdirectory(microdog40)
add_subdirectory(microdog40)
add_subdirectory(microdog40d)

View File

@ -0,0 +1,13 @@
project(microdog40d)
message(STATUS "Project " ${PROJECT_NAME})
set(SRC ${PT_ROOT_MAIN}/sec/microdog40)
set(SOURCE_FILES
${SRC}/main.c
${SRC}/microdog40d.c
${SRC}/microdog40.c)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} crypt util pthread)

View File

@ -0,0 +1,54 @@
#include <unistd.h>
#include <signal.h>
#include "hook/patch/microdog40.c"
#include "util/log.h"
#include "util/fs.h"
#include "util/mem.h"
void shutdown(int);
int main(int argc, char *argv[])
{
if (argc < 2) {
printf( "Usage: %s <keyfile.bin> [debug]\n", argv[0] );
return 1;
}
for (int i = 0; i < argc; i++) {
if (!strcmp(argv[i], "debug")) {
util_log_set_level(LOG_LEVEL_DEBUG);
break;
}
}
size_t key_data_len;
void* key_data;
if (!util_file_load(argv[1], &key_data, &key_data_len, false)) {
log_error("Loading key file %s failed", argv[1]);
return 2;
}
log_info("Running Microdog 4.0 Emulator");
patch_microdog40_init(key_data, key_data_len);
util_xfree(&key_data);
signal(SIGINT, shutdown);
// Run Daemon
while(true) {
sleep(2);
if (!sec_microdog40d_is_running()){
return 0;
}
}
}
void shutdown(int sig)
{
patch_microdog40_shutdown();
}

View File

@ -15,6 +15,7 @@ static const char* sec_microdog40d_sock_path = "/var/run/microdog/u.daemon";
static bool sec_microdog40d_run_d;
static bool sec_microdog40d_is_running_d;
struct timeval tv;
void sec_microdog40d_init(const uint8_t* key_data, size_t len)
{
@ -49,6 +50,13 @@ void sec_microdog40d_run(void)
return;
}
tv.tv_sec=5;
tv.tv_usec = 0;
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,&tv,sizeof(tv)) < 0) {
sec_microdog40d_is_running_d = false;
return;
}
memset(&peer_addr, 0, sizeof(struct sockaddr_un));
peer_addr.sun_family = AF_UNIX;
strcpy(peer_addr.sun_path, sec_microdog40d_sock_path);
@ -72,6 +80,8 @@ void sec_microdog40d_run(void)
if (errno == EBADF) {
break;
} else if (errno == EAGAIN) {
continue;
} else {
log_error("Receiving data failed: %s", strerror(errno));
sec_microdog40d_is_running_d = false;
@ -106,4 +116,4 @@ bool sec_microdog40d_is_running(void)
void sec_microdog40d_shutdown(void)
{
sec_microdog40d_run_d = false;
}
}