/* Function: setCompnameFromFile command line command to set computer name from file. Uses a list of files to find computer name. List consists of command line parameters and hard coded *\\device\\floppy0\\compname.txt*. Tries to read each file and extract the computer name in the list till a valid one is found. This is set as computer name afterwards. Parameters: io - <IO>-Controller args - command line */ void setCompnameFromFile(IO &io,char *args) { Indenter i(io); int numFiles=mainSingleton->getArgc(); char **valueNames=(char**)io.malloc(4*numFiles); char **cmdargs=mainSingleton->getArgs(); io.print("Computername file pipe: "); for (int i=1;i<numFiles;i++) { io.print(cmdargs[i]); io.print(", "); valueNames[i-1]=cmdargs[i]; } valueNames[numFiles-1]="\\device\\floppy0\\compname.txt"; io.println(valueNames[numFiles-1]); io.println("Reading computer-name from ..."); for (int i=0;i<numFiles;i++) { io.println(valueNames[i]); wchar_t *buffer2=readComputerNameFromFile(io,io.char2wchar(valueNames[i])); if (buffer2!=0) { setComputerName(io,buffer2); io.free(buffer2); io.free(valueNames); return; } } io.free(valueNames); }
void showNoWrite(IO &io2,char *args) { //ULONG status = NtInitializeRegistry(2); //CHECKER(status); unsigned int addr=0x8066eb34; //CmpNoWrite char *c=(char*)addr; BYTE Value; IO_STRUCT io; memset(&io, 0, sizeof(io)); io.IoAddr = RdWrIoPort; io.pBuffer = (PVOID)(ULONG_PTR)addr; io.NumBytes = 1; io.Reserved4 = 1; io.Reserved6 = 1; ULONG status = ZwSystemDebugControl(DebugSysWriteIoSpace, &io, sizeof(io), NULL, 0,NULL); CHECKER(status) memset(&io, 0, sizeof(io)); io.IoAddr = RdWrIoPort; io.pBuffer = &Value; io.NumBytes = 1; io.Reserved4 = 1; io.Reserved6 = 1; status = ZwSystemDebugControl(DebugSysReadIoSpace, &io, sizeof(io), NULL, 0,NULL); CHECKER(status); if (Value == 1) { io2.println("NoWrite set"); /*Value = 0; memset(&io, 0, sizeof(io)); io.IoAddr = RdWrIoPort; io.pBuffer = &Value; io.NumBytes = 1; io.Reserved4 = 1; io.Reserved6 = 1; status = ZwSystemDebugControl(DebugSysWriteIoSpace, &io, sizeof(io), NULL, 0,NULL); CHECKER(status); memset(&io, 0, sizeof(io)); io.IoAddr = RdWrIoPort; io.pBuffer = (PVOID)(ULONG_PTR)addr; io.NumBytes = 1; io.Reserved4 = 1; io.Reserved6 = 1; status = ZwSystemDebugControl(DebugSysReadIoSpace, &io, sizeof(io), NULL, 0, NULL); CHECKER(status);*/ } else io2.println("NoWrite not set"); }
/* Function: setComputerNameCmd command line command for setting the computer name manually Parameters: io - <IO>-Controller args - command line argument string */ void setComputerNameCmd(IO &io,char *args) { Indenter i(io); if (strlen(args)<2) { io.println("Syntax: setComputerName <newComputerName>"); return; } io.print("Setting Computer Name to: "); io.println(args+1); setComputerName(io,io.char2wchar(args+1)); }
/* Function: setComputerName sets the computer name in the registry to the specified one Parameters: io - reference to the <IO>-Controller computerName - the designated computer name as UNICODE string */ void setComputerName(IO &io,WCHAR *computerName) { Indenter i(io); io.println("Setze Computernamen "); setRegistryValue(io,KeyNameBuffer,ComputerNameBuffer,computerName); setRegistryValue(io,KeyNameBuffer2,ComputerNameBuffer,computerName); setRegistryValue(io,Tcpip,L"Hostname",computerName); setRegistryValue(io,Tcpip,L"NV Hostname",computerName); }
void testRegKey(IO &io,char *args) { wchar_t buffer[1000]; _snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\Names\\%S",&args[1]); char buf[1000]; UnicodeString str(buffer); io.println(str.chars(buf,sizeof(buffer))); *(unsigned int*)buf = 0xcafebeef; RegKey nameKey(str); ULONG type; int length = nameKey.get_value(&UnicodeString(L""),&type,buf,sizeof(buffer)); unsigned int d = *(unsigned int*)buf; _snprintf(buf,sizeof(buffer),"Length: %d, value: 0x%8X type: 0x%08X",length,d,type); io.println(buf); _snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\%08X",type); RegKey userKey(buffer); length = userKey.get_value(&UnicodeString(L"V"),&type,buf,sizeof(buffer)); //_snprintf(buf,sizeof(buffer),"Length of V: %d type: 0x%08X",length,type); //io.println(buf); entry *es=read_entries(buf,V_ENTRY_COUNT); char buf2[1000]; io.println(UnicodeString((wchar_t *)es[1].data,(unsigned short)es[1].length).chars(buf2,sizeof(buf2))); es[USERNAME_E].data = L"Gustav"; es[USERNAME_E].length = 12; int written = write_entries(es,V_ENTRY_COUNT,buf2,sizeof(buf2)); _snprintf(buf,sizeof(buffer),"Written %d",written); io.println(buf); userKey.set_value(&UnicodeString(L"V"),type,buf2,written); userKey.flush(); }
void showName(IO &io,char *args) { if (!*args) { io.println("No username given"); return; } wchar_t buffer[1000]; _snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\Names\\%S",&args[1]); RegKey nameKey(buffer); char buf[1000]; if (!nameKey.valid()) { _snprintf(buf,sizeof(buf),"User not found: %s",&args[1]); io.println(buf); return; } ULONG type; int length = nameKey.get_value(&UnicodeString(L""),&type,buf,sizeof(buffer)); _snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\%08X",type); RegKey userKey(buffer); length = userKey.get_value(&UnicodeString(L"V"),&type,buf,sizeof(buffer)); entry *es=read_entries(buf,V_ENTRY_COUNT); char buf2[1000]; io.print("Name: "); io.println(UnicodeString((wchar_t *)es[USERNAME_E].data,(unsigned short)es[USERNAME_E].length).chars(buf2,sizeof(buf2))); io.print("Voller Name: "); io.println(UnicodeString((wchar_t *)es[FULLNAME_E].data,(unsigned short)es[FULLNAME_E].length).chars(buf2,sizeof(buf2))); }
void splitArgs(IO &io,char *args){ if (strlen(args)==0) return; int argc; UNICODE_STRING str; wchar_t *wstr; char buffer[100]; wstr=(wchar_t*)buffer; mbstowcs(wstr,args,50); NT::RtlInitUnicodeString(&str,wstr); str.Length-=2; char **argv=split_args(io,str.Buffer,str.Length/2,&argc); for (int i=0;i<argc;i++) io.println(argv[i]); }
void showAutoLogonName(IO &io,char *args) { RegKey k(L"Machine\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"); char buffer[40]; io.println(k.get_string_value(&UnicodeString(L"DefaultUsername")).chars(buffer,40)); }