mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2025-01-31 11:53:45 +01:00
Microdog 4.0 Emulator: Standalone
This commit is contained in:
parent
a26830219e
commit
f0040e5a1a
12
Package.mk
12
Package.mk
@ -174,6 +174,15 @@ $(zipdir)/pumpnet.zip: \
|
|||||||
$(V)echo ... $@
|
$(V)echo ... $@
|
||||||
$(V)zip -j $@ $^
|
$(V)zip -j $@ $^
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Security: Lexical sorting
|
||||||
|
|
||||||
|
$(zipdir)/security.zip: \
|
||||||
|
$(builddir)/bin/microdog40d \
|
||||||
|
| $(zipdir)/
|
||||||
|
$(V)echo ... $@
|
||||||
|
$(V)zip -j $@ $^
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Documentation
|
# Documentation
|
||||||
|
|
||||||
@ -234,6 +243,7 @@ $(builddir)/pumptools.zip: \
|
|||||||
$(zipdir)/pro2hook.zip \
|
$(zipdir)/pro2hook.zip \
|
||||||
$(zipdir)/prohook.zip \
|
$(zipdir)/prohook.zip \
|
||||||
$(zipdir)/pumpnet.zip \
|
$(zipdir)/pumpnet.zip \
|
||||||
|
$(zipdir)/security.zip \
|
||||||
$(zipdir)/x2hook.zip \
|
$(zipdir)/x2hook.zip \
|
||||||
$(zipdir)/zerohook.zip \
|
$(zipdir)/zerohook.zip \
|
||||||
CHANGELOG.md \
|
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
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
add_subdirectory(hasp)
|
add_subdirectory(hasp)
|
||||||
add_subdirectory(lockchip)
|
add_subdirectory(lockchip)
|
||||||
add_subdirectory(microdog34)
|
add_subdirectory(microdog34)
|
||||||
add_subdirectory(microdog40)
|
add_subdirectory(microdog40)
|
||||||
|
add_subdirectory(microdog40d)
|
||||||
|
13
cmake/src/main/sec/microdog40d/CMakeLists.txt
Normal file
13
cmake/src/main/sec/microdog40d/CMakeLists.txt
Normal 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)
|
54
src/main/sec/microdog40/main.c
Normal file
54
src/main/sec/microdog40/main.c
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -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_run_d;
|
||||||
static bool sec_microdog40d_is_running_d;
|
static bool sec_microdog40d_is_running_d;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
void sec_microdog40d_init(const uint8_t* key_data, size_t len)
|
void sec_microdog40d_init(const uint8_t* key_data, size_t len)
|
||||||
{
|
{
|
||||||
@ -49,6 +50,13 @@ void sec_microdog40d_run(void)
|
|||||||
return;
|
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));
|
memset(&peer_addr, 0, sizeof(struct sockaddr_un));
|
||||||
peer_addr.sun_family = AF_UNIX;
|
peer_addr.sun_family = AF_UNIX;
|
||||||
strcpy(peer_addr.sun_path, sec_microdog40d_sock_path);
|
strcpy(peer_addr.sun_path, sec_microdog40d_sock_path);
|
||||||
@ -72,6 +80,8 @@ void sec_microdog40d_run(void)
|
|||||||
|
|
||||||
if (errno == EBADF) {
|
if (errno == EBADF) {
|
||||||
break;
|
break;
|
||||||
|
} else if (errno == EAGAIN) {
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
log_error("Receiving data failed: %s", strerror(errno));
|
log_error("Receiving data failed: %s", strerror(errno));
|
||||||
sec_microdog40d_is_running_d = false;
|
sec_microdog40d_is_running_d = false;
|
||||||
@ -106,4 +116,4 @@ bool sec_microdog40d_is_running(void)
|
|||||||
void sec_microdog40d_shutdown(void)
|
void sec_microdog40d_shutdown(void)
|
||||||
{
|
{
|
||||||
sec_microdog40d_run_d = false;
|
sec_microdog40d_run_d = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user