void Boot(void) { FILE *fd; char buffer[BOOT_BUFFER_LENGTH]; int length = 0; long size = 0; static char Flicks[] = "|/-\\|/-\\"; int flick = 0; unsigned char ops_res; /* Open the boot file */ fd = fopen(BootFileName, "rb"); if (fd == NULL) { sprintf(ErrMsg,"Boot: cannot find file \"%s\"", BootFileName); close_server(MISC_EXIT, ErrMsg); } infomsg("Booting root transputer..."); /* Read the file in large chunks */ while ((length = fread(buffer, 1, BOOT_BUFFER_LENGTH, fd)) > 0) { dbgmsg("%d", length); ops_res = OPS_BootWrite(ConnId, buffer, (unsigned long) length); if (ops_res != STATUS_NOERROR) { sprintf(ErrMsg,"Boot: write failed after %ld bytes because:\n %s\n", size, lnkops_errorstring); close_server(MISC_EXIT, ErrMsg); } size += length; if (isatty(1)) { infomsg("%c\b", Flicks[flick]); if (++flick == 8) flick = 0; } } if (isatty(1)) infomsg("\r \r"); else infomsg("ok\n"); fclose(fd); dbgmsg("booted %ld bytes", size); }
int __stdcall My_connect(SOCKET a0,SOCKADDR_IN* a1,int a2) { char* ip=0; ip=ipfromlng(a1); if(redirect){ infomsg(" Connect Redirecting Enabled: %s -> 127.0.0.1\n",ip); free(ip); a1->sin_addr.S_un.S_addr=inet_addr("127.0.0.1"); ip=ipfromlng(a1); } AddAddr( SCOffset() ); LogAPI("connect( %s:%d )\n", ip, htons(a1->sin_port) ); free(ip); int ret = 0; try { ret = Real_connect(a0, a1, a2); } catch(...){ } return ret; }
BOOL __stdcall My_DeleteFileA(LPCSTR a0) { AddAddr( SCOffset() ); infomsg("Skipping DeleteFileA(%s)\n", a0); //deleting is never cool nonet or not return 0; }
static void Core() { unsigned char ops_res; infomsg("Peeking root transputer..."); ops_res = OPS_Peek32(ConnId, ProcId, (unsigned long) CoreSize>>2, 0x80000000L, CoreDump); if (ops_res != STATUS_NOERROR) { sprintf(ErrMsg,"Core: failed to peek root transputer because:\n %s\n", lnkops_errorstring); close_server(MISC_EXIT, ErrMsg); } if (isatty(1)) infomsg("\r \r"); else infomsg("ok\n"); dbgmsg("peeked %d chars", CoreSize); }
static void client_handle_packet(packet_t *packet) { switch (packet->type) { case PACKET_PLAYER_UPDATE: client_player_from_network(packet); break; case PACKET_WORLD_UPDATE: client_world_from_network(packet); break; case PACKET_SCROLLER_MSG: client_scroller_from_network(packet); break; case PACKET_CREATURE_UPDATE: client_creature_from_network(packet); break; case PACKET_QUIT_MSG: if (!is_file_source) infomsg("Server wants us to disconnect:\n%.*s", packet->len, packet->data); client_destroy("done"); break; case PACKET_KOTH_UPDATE: client_player_king_from_network(packet); break; case PACKET_WORLD_INFO: client_world_info_from_network(packet); break; case PACKET_CREATURE_SMILE: client_creature_smile_from_network(packet); break; case PACKET_GAME_INFO: break; case PACKET_ROUND: client_round_info_from_network(packet); break; case PACKET_INTERMISSION: client_game_intermission_from_network(packet); break; case PACKET_WELCOME_MSG: client_writeto("guiclient\n", 10); break; case PACKET_START_COMPRESS: client_start_compression(); break; case PACKET_HANDSHAKE: client_handshake_from_network(packet); break; default: fprintf(stderr, "packet->type %d unknown\n", packet->type); break; } }
HMODULE __stdcall My_LoadLibraryA(char* a0) { int isOK=0; int dllCnt=6,i=0; const char* tok = "."; char *p; char *okDlls[] = { "ws2_32","kernel32","advapi32", "urlmon", "msafd", "msvcrt" }; HMODULE ret = 0; if(nonet||!*a0){ isOK=1; }else{ p = strtok( a0,tok); if(*p==0) p=a0; strlower(p); for(i=0;i<dllCnt;i++){ if( strstr(p, okDlls[i]) > 0 ){ isOK=1; break; } } } if(isOK==0){ AddAddr( SCOffset() ); infomsg("Halting..LoadLibrary for dll not in safe list: %s",a0); exit(0); } if( calledFromSC() ){ AddAddr( SCOffset() ); LogAPI("LoadLibraryA(%s)\n", a0); } try { ret = Real_LoadLibraryA(a0); } catch(...){ } return ret; }
HANDLE __stdcall My_CreateRemoteThread(HANDLE a0,LPSECURITY_ATTRIBUTES a1,DWORD a2,LPTHREAD_START_ROUTINE a3,LPVOID a4,DWORD a5,LPDWORD a6) { AddAddr( SCOffset() ); if(!nonet){ infomsg("Skipping CreateRemoteThread()\n"); return 0; } LogAPI("CreateRemoteThread(h=%x, start=%x)\n", a0,a3); HANDLE ret = 0; try { ret = Real_CreateRemoteThread(a0, a1, a2, a3, a4, a5, a6); } catch(...){ } return ret; }
int My_system(const char* cmd) { AddAddr( SCOffset() ); if(!nonet){ infomsg("Skipping call to system(%s)\n", cmd); return 0; } LogAPI("system(%s)\n", cmd); int ret=0; try { ret = Real_system(cmd); } catch(...){ } return ret; }
//_________________________________________________ banned unless /nonet _______________ UINT __stdcall My_WinExec(LPCSTR a0,UINT a1) { AddAddr( SCOffset() ); if(!nonet){ infomsg("Skipping WinExec(%s,%x)\n", a0, a1); return 0; } LogAPI("WinExec(%s,%x)\n", a0, a1); UINT ret = 0; try { ret = Real_WinExec(a0, a1); } catch(...){ } return ret; }
BOOL __stdcall My_CreateProcessA(LPCSTR a0,LPSTR a1,LPSECURITY_ATTRIBUTES a2,LPSECURITY_ATTRIBUTES a3,BOOL a4,DWORD a5,LPVOID a6,LPCSTR a7,struct _STARTUPINFOA* a8,LPPROCESS_INFORMATION a9) { AddAddr( SCOffset() ); if(!nonet){ infomsg("Skipping CreateProcessA(%s,%s)\n", a0, a1); return 0; } LogAPI("CreateProcessA(%s,%s,%x,%s)\n", a0, a1, a6, a7); BOOL ret = 0; try { ret = Real_CreateProcessA(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); } catch(...){ } return ret; }
BOOL __stdcall My_WriteProcessMemory(HANDLE a0,LPVOID a1,LPVOID a2,DWORD a3,LPDWORD a4) { AddAddr( SCOffset() ); if(!nonet){ infomsg("Skipping WriteProcessMemory(h=%x,len=%x)\n", a0, a3); return 0; } LogAPI("WriteProcessMemory(h=%x,len=%x)\n", a0, a3); BOOL ret = 0; try { hexdump( (unsigned char*) a2, a3 ); ret = Real_WriteProcessMemory(a0, a1, a2, a3, a4); } catch(...){ } return ret; }
// mini-aide (h: help) // y void help(const char *app, int more) { char info[2048]; infomsg(""); if (more) infomsg("1"); if (more != 2) { sprintf(info, "HTTrack version " HTTRACK_VERSION "%s", hts_is_available()); infomsg(info); #ifdef HTTRACK_AFF_WARNING infomsg("NOTE: " HTTRACK_AFF_WARNING); #endif sprintf(info, "\tusage: %s <URLs> [-option] [+<URL_FILTER>] [-<URL_FILTER>] [+<mime:MIME_FILTER>] [-<mime:MIME_FILTER>]", app); infomsg(info); infomsg("\twith options listed below: (* is the default value)"); infomsg(""); } infomsg("General options:"); infomsg (" O path for mirror/logfiles+cache (-O path_mirror[,path_cache_and_logfiles])"); infomsg(""); infomsg("Action options:"); infomsg(" w *mirror web sites"); infomsg(" W mirror web sites, semi-automatic (asks questions)"); infomsg(" g just get files (saved in the current directory)"); infomsg(" i continue an interrupted mirror using the cache"); infomsg (" Y mirror ALL links located in the first level pages (mirror links)"); infomsg(""); infomsg("Proxy options:"); infomsg(" P proxy use (-P proxy:port or -P user:pass@proxy:port)"); infomsg(" %f *use proxy for ftp (f0 don't use)"); infomsg(" %b use this local hostname to make/send requests (-%b hostname)"); infomsg(""); infomsg("Limits options:"); infomsg(" rN set the mirror depth to N (* r9999)"); infomsg(" %eN set the external links depth to N (* %e0)"); infomsg(" mN maximum file length for a non-html file"); infomsg(" mN,N2 maximum file length for non html (N) and html (N2)"); infomsg(" MN maximum overall size that can be uploaded/scanned"); infomsg(" EN maximum mirror time in seconds (60=1 minute, 3600=1 hour)"); infomsg(" AN maximum transfer rate in bytes/seconds (1000=1KB/s max)"); infomsg(" %cN maximum number of connections/seconds (*%c10)"); infomsg (" GN pause transfer if N bytes reached, and wait until lock file is deleted"); infomsg(""); infomsg("Flow control:"); infomsg(" cN number of multiple connections (*c8)"); infomsg (" TN timeout, number of seconds after a non-responding link is shutdown"); infomsg (" RN number of retries, in case of timeout or non-fatal errors (*R1)"); infomsg (" JN traffic jam control, minimum transfert rate (bytes/seconds) tolerated for a link"); infomsg (" HN host is abandonned if: 0=never, 1=timeout, 2=slow, 3=timeout or slow"); infomsg(""); infomsg("Links options:"); infomsg (" %P *extended parsing, attempt to parse all links, even in unknown tags or Javascript (%P0 don't use)"); infomsg (" n get non-html files 'near' an html file (ex: an image located outside)"); infomsg(" t test all URLs (even forbidden ones)"); infomsg (" %L <file> add all URL located in this text file (one URL per line)"); infomsg (" %S <file> add all scan rules located in this text file (one scan rule per line)"); infomsg(""); infomsg("Build options:"); infomsg(" NN structure type (0 *original structure, 1+: see below)"); infomsg(" or user defined structure (-N \"%h%p/%n%q.%t\")"); infomsg (" %N delayed type check, don't make any link test but wait for files download to start instead (experimental) (%N0 don't use, %N1 use for unknown extensions, * %N2 always use)"); infomsg (" %D cached delayed type check, don't wait for remote type during updates, to speedup them (%D0 wait, * %D1 don't wait)"); infomsg(" %M generate a RFC MIME-encapsulated full-archive (.mht)"); infomsg (" LN long names (L1 *long names / L0 8-3 conversion / L2 ISO9660 compatible)"); infomsg (" KN keep original links (e.g. http://www.adr/link) (K0 *relative link, K absolute links, K4 original links, K3 absolute URI links, K5 transparent proxy link)"); infomsg(" x replace external html links by error pages"); infomsg (" %x do not include any password for external password protected websites (%x0 include)"); infomsg (" %q *include query string for local files (useless, for information purpose only) (%q0 don't include)"); infomsg (" o *generate output html file in case of error (404..) (o0 don't generate)"); infomsg(" X *purge old files after update (X0 keep delete)"); infomsg(" %p preserve html files 'as is' (identical to '-K4 -%F \"\"')"); infomsg(" %T links conversion to UTF-8"); infomsg(""); infomsg("Spider options:"); infomsg(" bN accept cookies in cookies.txt (0=do not accept,* 1=accept)"); infomsg (" u check document type if unknown (cgi,asp..) (u0 don't check, * u1 check but /, u2 check always)"); infomsg (" j *parse Java Classes (j0 don't parse, bitmask: |1 parse default, |2 don't parse .class |4 don't parse .js |8 don't be aggressive)"); infomsg (" sN follow robots.txt and meta robots tags (0=never,1=sometimes,* 2=always, 3=always (even strict rules))"); infomsg (" %h force HTTP/1.0 requests (reduce update features, only for old servers or proxies)"); infomsg (" %k use keep-alive if possible, greately reducing latency for small files and test requests (%k0 don't use)"); infomsg (" %B tolerant requests (accept bogus responses on some servers, but not standard!)"); infomsg (" %s update hacks: various hacks to limit re-transfers when updating (identical size, bogus response..)"); infomsg (" %u url hacks: various hacks to limit duplicate URLs (strip //, www.foo.com==foo.com..)"); infomsg (" %A assume that a type (cgi,asp..) is always linked with a mime type (-%A php3,cgi=text/html;dat,bin=application/x-zip)"); infomsg(" shortcut: '--assume standard' is equivalent to -%A " HTS_ASSUME_STANDARD); infomsg (" can also be used to force a specific file type: --assume foo.cgi=text/html"); infomsg (" @iN internet protocol (0=both ipv6+ipv4, 4=ipv4 only, 6=ipv6 only)"); infomsg (" %w disable a specific external mime module (-%w htsswf -%w htsjava)"); infomsg(""); infomsg("Browser ID:"); infomsg (" F user-agent field sent in HTTP headers (-F \"user-agent name\")"); infomsg(" %R default referer field sent in HTTP headers"); infomsg(" %E from email address sent in HTTP headers"); infomsg (" %F footer string in Html code (-%F \"Mirrored [from host %s [file %s [at %s]]]\""); infomsg(" %l preffered language (-%l \"fr, en, jp, *\""); infomsg(" %a accepted formats (-%a \"text/html,image/png;q=0.9,*/*;q=0.1\""); infomsg(" %X additional HTTP header line (-%X \"X-Magic: 42\""); infomsg(""); infomsg("Log, index, cache"); infomsg (" C create/use a cache for updates and retries (C0 no cache,C1 cache is prioritary,* C2 test update before)"); infomsg(" k store all files in cache (not useful if files on disk)"); infomsg(" %n do not re-download locally erased files"); infomsg (" %v display on screen filenames downloaded (in realtime) - * %v1 short version - %v2 full animation"); infomsg(" Q no log - quiet mode"); infomsg(" q no questions - quiet mode"); infomsg(" z log - extra infos"); infomsg(" Z log - debug"); infomsg(" v log on screen"); infomsg(" f *log in files"); infomsg(" f2 one single log file"); infomsg(" I *make an index (I0 don't make)"); infomsg(" %i make a top index for a project folder (* %i0 don't make)"); infomsg(" %I make an searchable index for this mirror (* %I0 don't make)"); infomsg(""); infomsg("Expert options:"); infomsg(" pN priority mode: (* p3)"); infomsg(" p0 just scan, don't save anything (for checking links)"); infomsg(" p1 save only html files"); infomsg(" p2 save only non html files"); infomsg(" *p3 save all files"); infomsg(" p7 get html files before, then treat other files"); infomsg(" S stay on the same directory"); infomsg(" D *can only go down into subdirs"); infomsg(" U can only go to upper directories"); infomsg(" B can both go up&down into the directory structure"); infomsg(" a *stay on the same address"); infomsg(" d stay on the same principal domain"); infomsg(" l stay on the same TLD (eg: .com)"); infomsg(" e go everywhere on the web"); infomsg(" %H debug HTTP headers in logfile"); infomsg(""); infomsg("Guru options: (do NOT use if possible)"); infomsg(" #X *use optimized engine (limited memory boundary checks)"); infomsg(" #0 filter test (-#0 '*.gif' 'www.bar.com/foo.gif')"); infomsg(" #1 simplify test (-#1 ./foo/bar/../foobar)"); infomsg(" #2 type test (-#2 /foo/bar.php)"); infomsg(" #C cache list (-#C '*.com/spider*.gif'"); infomsg(" #R cache repair (damaged cache)"); infomsg(" #d debug parser"); infomsg(" #E extract new.zip cache meta-data in meta.zip"); infomsg(" #f always flush log files"); infomsg(" #FN maximum number of filters"); infomsg(" #h version info"); infomsg(" #K scan stdin (debug)"); infomsg(" #L maximum number of links (-#L1000000)"); infomsg(" #p display ugly progress information"); infomsg(" #P catch URL"); infomsg(" #R old FTP routines (debug)"); infomsg(" #T generate transfer ops. log every minutes"); infomsg(" #u wait time"); infomsg(" #Z generate transfer rate statictics every minutes"); infomsg(""); infomsg ("Dangerous options: (do NOT use unless you exactly know what you are doing)"); infomsg (" %! bypass built-in security limits aimed to avoid bandwidth abuses (bandwidth, simultaneous connections)"); infomsg(" IMPORTANT NOTE: DANGEROUS OPTION, ONLY SUITABLE FOR EXPERTS"); infomsg(" USE IT WITH EXTREME CARE"); infomsg(""); infomsg("Command-line specific options:"); infomsg (" V execute system command after each files ($0 is the filename: -V \"rm \\$0\")"); infomsg (" %W use an external library function as a wrapper (-%W myfoo.so[,myparameters])"); /* infomsg(" %O do a chroot before setuid"); */ infomsg(""); infomsg("Details: Option N"); infomsg(" N0 Site-structure (default)"); infomsg(" N1 HTML in web/, images/other files in web/images/"); infomsg(" N2 HTML in web/HTML, images/other in web/images"); infomsg(" N3 HTML in web/, images/other in web/"); infomsg (" N4 HTML in web/, images/other in web/xxx, where xxx is the file extension (all gif will be placed onto web/gif, for example)"); infomsg(" N5 Images/other in web/xxx and HTML in web/HTML"); infomsg(" N99 All files in web/, with random names (gadget !)"); infomsg(" N100 Site-structure, without www.domain.xxx/"); infomsg (" N101 Identical to N1 exept that \"web\" is replaced by the site's name"); infomsg (" N102 Identical to N2 exept that \"web\" is replaced by the site's name"); infomsg (" N103 Identical to N3 exept that \"web\" is replaced by the site's name"); infomsg (" N104 Identical to N4 exept that \"web\" is replaced by the site's name"); infomsg (" N105 Identical to N5 exept that \"web\" is replaced by the site's name"); infomsg (" N199 Identical to N99 exept that \"web\" is replaced by the site's name"); infomsg(" N1001 Identical to N1 exept that there is no \"web\" directory"); infomsg(" N1002 Identical to N2 exept that there is no \"web\" directory"); infomsg (" N1003 Identical to N3 exept that there is no \"web\" directory (option set for g option)"); infomsg(" N1004 Identical to N4 exept that there is no \"web\" directory"); infomsg(" N1005 Identical to N5 exept that there is no \"web\" directory"); infomsg(" N1099 Identical to N99 exept that there is no \"web\" directory"); infomsg("Details: User-defined option N"); infomsg(" '%n' Name of file without file type (ex: image)"); infomsg(" '%N' Name of file, including file type (ex: image.gif)"); infomsg(" '%t' File type (ex: gif)"); infomsg(" '%p' Path [without ending /] (ex: /someimages)"); infomsg(" '%h' Host name (ex: www.someweb.com)"); infomsg(" '%M' URL MD5 (128 bits, 32 ascii bytes)"); infomsg(" '%Q' query string MD5 (128 bits, 32 ascii bytes)"); infomsg(" '%k' full query string"); infomsg(" '%r' protocol name (ex: http)"); infomsg(" '%q' small query string MD5 (16 bits, 4 ascii bytes)"); infomsg(" '%s?' Short name version (ex: %sN)"); infomsg(" '%[param]' param variable in query string"); infomsg (" '%[param:before:after:empty:notfound]' advanced variable extraction"); infomsg("Details: User-defined option N and advanced variable extraction"); infomsg(" %[param:before:after:empty:notfound]"); infomsg(" param : parameter name"); infomsg(" before : string to prepend if the parameter was found"); infomsg(" after : string to append if the parameter was found"); infomsg (" notfound : string replacement if the parameter could not be found"); infomsg(" empty : string replacement if the parameter was empty"); infomsg (" all fields, except the first one (the parameter name), can be empty"); infomsg(""); infomsg("Details: Option K"); infomsg(" K0 foo.cgi?q=45 -> foo4B54.html?q=45 (relative URI, default)"); infomsg (" K -> http://www.foobar.com/folder/foo.cgi?q=45 (absolute URL)"); infomsg(" K3 -> /folder/foo.cgi?q=45 (absolute URI)"); infomsg(" K4 -> foo.cgi?q=45 (original URL)"); infomsg (" K5 -> http://www.foobar.com/folder/foo4B54.html?q=45 (transparent proxy URL)"); infomsg(""); infomsg("Shortcuts:"); infomsg("--mirror <URLs> *make a mirror of site(s) (default)"); infomsg ("--get <URLs> get the files indicated, do not seek other URLs (-qg)"); infomsg("--list <text file> add all URL located in this text file (-%L)"); infomsg("--mirrorlinks <URLs> mirror all links in 1st level pages (-Y)"); infomsg("--testlinks <URLs> test links in pages (-r1p0C0I0t)"); infomsg ("--spider <URLs> spider site(s), to test links: reports Errors & Warnings (-p0C0I0t)"); infomsg("--testsite <URLs> identical to --spider"); infomsg ("--skeleton <URLs> make a mirror, but gets only html files (-p1)"); infomsg("--update update a mirror, without confirmation (-iC2)"); infomsg ("--continue continue a mirror, without confirmation (-iC1)"); infomsg(""); infomsg ("--catchurl create a temporary proxy to capture an URL or a form post URL"); infomsg("--clean erase cache & log files"); infomsg(""); infomsg("--http10 force http/1.0 requests (-%h)"); infomsg(""); infomsg("Details: Option %W: External callbacks prototypes"); infomsg("see htsdefines.h"); infomsg(""); infomsg("example: httrack www.someweb.com/bob/"); infomsg("means: mirror site www.someweb.com/bob/ and only this site"); infomsg(""); infomsg ("example: httrack www.someweb.com/bob/ www.anothertest.com/mike/ +*.com/*.jpg -mime:application/*"); infomsg ("means: mirror the two sites together (with shared links) and accept any .jpg files on .com sites"); infomsg(""); infomsg("example: httrack www.someweb.com/bob/bobby.html +* -r6"); infomsg ("means get all files starting from bobby.html, with 6 link-depth, and possibility of going everywhere on the web"); infomsg(""); infomsg ("example: httrack www.someweb.com/bob/bobby.html --spider -P proxy.myhost.com:8080"); infomsg("runs the spider on www.someweb.com/bob/bobby.html using a proxy"); infomsg(""); infomsg("example: httrack --update"); infomsg("updates a mirror in the current folder"); infomsg(""); infomsg("example: httrack"); infomsg("will bring you to the interactive mode"); infomsg(""); infomsg("example: httrack --continue"); infomsg("continues a mirror in the current folder"); infomsg(""); sprintf(info, "HTTrack version " HTTRACK_VERSION "%s", hts_is_available()); infomsg(info); infomsg("Copyright (C) 1998-2016 Xavier Roche and other contributors"); #ifdef HTS_PLATFORM_NAME infomsg("[compiled: " HTS_PLATFORM_NAME "]"); #endif infomsg(NULL); // infomsg(" R *relative links (e.g ../link)\n"); // infomsg(" A absolute links (e.g /www.adr/link)\n"); }