Jump to content

Mark-

Members
  • Content Count

    207
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mark-

  1. Also posted on Embarcadero site. Hello, Working on creating a better method to fingerprint a computer without the issues of MAC ID, memory size etc.. I was looking at the "ProductID" in the registry and found that it is only for show and can be changed to any value without altering the OS operation. Several other product ID type values are present as binary keys. I found some C# code (http://www.mrpear.net/en/blog/1207/how-to-get-windows-product-key-from-digitalproductid-exported-out-of-registry) that could convert the binary to the product key code but no code in Delphi. I converted it to Delphi and it appears to work, somewhat. It returned the correct product code on a W10 64-bit Pro and a W7 32-bit Pro install. Two places in the code I am not sure are correct. Other test returned a code but, I could not verify it was correct. On a W7 64-bit, I have the code, from the CD and the returned code was not correct. I am posting the code for anyone that might need it and check if others have a better solution or comments. Cheers, Mark program GetProdIDs; {$APPTYPE CONSOLE} {$R *.res} uses Winapi.Windows, System.SysUtils, System.Win.Registry; procedure ReadRegisteryBinary(rKey:nativeUInt; const path,keyName:string; var buf; var bufSize:integer); var r:TRegistry; begin r:=nil; try r:=TRegistry.Create(KEY_READ or KEY_WOW64_64KEY); r.RootKey:=rKey; if not r.OpenKey(path,false) then Exit; if (r.GetDataSize(keyName) > bufSize) then begin bufSize:=0; Exit; end; try bufSize:=r.ReadBinaryData(keyName,buf,bufSize); except on ERegistryException do bufSize:=0; end; finally r.Free; end; end; function DecodeDigitalProductId(var data:array of byte; dataSize:integer):string; const keyOffset = 52; digits = ANSIString('BCDFGHJKMPQRTVWXY2346789'); var // isWin8:byte; last,i,current,j:integer; key,keypart1,keypart2:string; begin result:=''; // isWin8:=((data[66] div 6) and 1); //not sure about this data[66]:=(data[66] and $F7) {or ((isWin8 and $02) * 4)}; for i:=24 downto 0 do begin current:=0; for j:=14 downto 0 do begin current:=current * 256; current:=data[j + keyOffset] + current; data[j + keyOffset]:=(current div 24); current:=current mod 24; last:=current; end; if (((current + 1) > 0) and ((current + 1) <= length(digits))) then key:=digits[current + 1] + key; end; keypart1:=key.Substring(1, last); keypart2:=key.Substring(last + 1, key.Length - (last + 1)); key:=keypart1 + 'N' + keypart2; //not sure if this is correct, any keys without 'N' i:=5; while (i < key.Length) do begin key:=key.Insert(i, '-'); Inc(i,6); end; result:=key; end; function GetProductID(const idStr:string):string; var dataSize:integer; data:array[0..$FFF] of byte; begin dataSize:=length(data); ReadRegisteryBinary(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows NT\CurrentVersion',idStr,data,dataSize); if (dataSize > 0) then result:=DecodeDigitalProductId(data,dataSize) else result:=''; end; function ReadProductIDString:string; var r:TRegistry; begin result:=''; r:=nil; try r:=TRegistry.Create(KEY_READ or KEY_WOW64_64KEY); r.RootKey:=HKEY_LOCAL_MACHINE; if not r.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion',false) then Exit; try result:=r.ReadString('ProductId'); except on ERegistryException do result:='error'; end; finally r.Free; end; end; begin try Writeln('ProductId: ' + ReadProductIDString); Writeln(''); Writeln('DigitalProductId: ' + GetProductID('DigitalProductId')); Writeln('DigitalProductId1: ' + GetProductID('DigitalProductId1')); Writeln('DigitalProductId2: ' + GetProductID('DigitalProductId2')); Writeln('DigitalProductId3: ' + GetProductID('DigitalProductId3')); Writeln('DigitalProductId4: ' + GetProductID('DigitalProductId4')); Writeln('DigitalProductId5: ' + GetProductID('DigitalProductId5')); Writeln(''); Writeln('Press enter/return'); Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; //if the OS was updated using the free version one of these might be the product ID code // Windows 10 Home - YTMG3-N6DKC-DKB77-7M9GH-8HVX7 // Windows 10 Pro - VK7JG-NPHTM-C97JM-9MPGT-3V66T // Windows 10 Home SL- BT79Q-G7N6G-PGBYW-4YWX6-6F4BT // Windows 10 Pro VL-MAK - QJNXR-7D97Q-K7WH4-RYWQ8-6MT6Y end.
  2. Mark-

    Windows product ID (from the registry)...

    Thanks very much for the code. It is very interesting. Am I wrong to think that some values, while using WMI to fetch the values, WMI retrieves the values from the registry?
  3. Mark-

    Windows product ID (from the registry)...

    Never used PowerShell much. The product version seems to be the same as the OS. The path has V1.0 at the end. OK installed it and much more data. Thanks,
  4. Mark-

    Windows product ID (from the registry)...

    Thanks The result: WindowsProductName WindowsVersion OsHardwareAbstractionLayer ------------------ -------------- -------------------------- Windows 10 Pro 1809 I ran it with no input parameters and most of the results are blank.
  5. Mark-

    Windows product ID (from the registry)...

    Thanks. Changed to: isWin8:=((data[66] div 6) and 1); if (isWin8 <> 0) then data[66]:=(data[66] and $F7) or ((isWin8 and $02) * 4); Did you see: key:=keypart1 + 'N' + keypart2; //not sure if this is correct, any keys without 'N'
  6. Hello Is there a method/way/solution to configure an THttpServer instance to use a random free port number when "Start" is called? Cheers, Mark
  7. Thanks. That would not compile for THttpServer and my messing with it to get it to compile, did not return the correct port number when I set the port to 8080 for example.
  8. When I set the port to 0 and call "Start" the port number does not change. Perhaps I am doing something wrong.
  9. I am the client (program) and server (a service) on the same computer. I do not want to use a fixed port, to avoid conflicts. When the service starts it would open the port (wanting any free port number) and save the port number to a file the client reads when it starts.
  10. Hello, Using cellular, depending on many factors, I can get many 500 error codes that abort the transfer. I am using FtpClient.Transmit; with binary, passive. What is the correct way to "resume" the transfer? Thanks, Mark
  11. Mark-

    FTP transfers...

    Thanks. Without a doubt it does not work here without me calling CWD after logon. Is CWDAsync used? I ask because this is testing on cellular. If I call CWDAsync after logon no change, file is uploaded to root. If I call CWD, the file is uploaded to the correct path.
  12. Mark-

    FTP transfers...

    > I've not used FtpUpOneFile myself for many years, it was written for another client and worked in their circumstance, need to test it. Very good.
  13. Mark-

    FTP transfers...

    If I call CWD after logon and before FtpUpOneFile, the files upload to the correct paths. Perhaps I am not setting a property correctly or at all. Or calling CWD first is by design.
  14. Mark-

    FTP transfers...

    Hello, OK I spoke too soon and I cannot locate my error. I am using FtpUpOneFile. The source path is OK The filename is OK The target path is '/public_html/downloads/'. All the files are being placed at the root, '/'. I set the TarDir and SrcDir before calling logon. and the FtpUpOneFile is correct. I see "fServRootDir" is '/'. I see PWD and DirResult is '/'. I see fServBaseDir and fCurRemDir both being set to '/public_html/downloads/'. In IntUpOne , HostDirName := '/' ; Not sure it is relevant. Then Put is called and the file uploads to the root. These are the same paths used before switching to FtpUpOneFile. What am I doing wrong/missing? Thanks, Mark
  15. Mark-

    FTP transfers...

    Thanks Angus, François and all the contributors. Using the example, I was able to replace the TFtpClient with TIcsFtpMulti and watch the FTP resume when the transfer failed from the server returning an error or loss of connection. I used the single file, FtpUpOneFile function. Cheers, Mark
  16. Mark-

    FTP transfers...

    Thank you, I will look into it.
  17. Hello, Never used multicast before and not having success. I must send a request to a device at 192.168.1.51 port 1500 using UDP. The device will begin multicasting data on address 224.0.0.0 port 1500. I send the request and I see the device sending the data on Wireshark. I just do not get any OnDataAvaliable calls. I set the TWSocket as: multiSocket.Proto:='udp'; multiSocket.Addr:='192.168.8.169'; //nic to bind to multiSocket.Port:=portNum; //1500 multiSocket.MultiCast:=true; multiSocket.MultiCastAddrStr:='224.0.0.0'; //this is the dst address I see in wireshark, //tried the sender ip address and got error IP_ADD_MEMBERSHIP ; multiSocket.ReuseAddr:=true; multiSocket.Listen; No error, no data. I can configure the multicast address on the device. Should the address be changed? What am I doing wrong? Thanks, Mark
  18. Resolved. W10 Firewall was allowing outgoing but not incoming.
  19. Hello, Can the ICS logger log all data sent/received? All "LogOptions" enabled, no data bytes. TIcsLoggerVersion = 840; Thanks, Mark
  20. Mark-

    IC Logger...

    Thanks for the reply. It actually was a logic mistake in the OnDataAvailable event handler In the event I only read the data to a buffer, check a few things and then possibly post a message for handling, then exit. The issue was a message was posted when it should not have been. I have to thank W10 Pro 32 bit for exposing the issue. Why the three other test operating systems did not expose the issue,.. not sure. The code had been running for years. Perhaps the mistake surfaced because the OS and program were running in a VM.
  21. Mark-

    IC Logger...

    Thanks for the answer. That was the conclusion I came to looking around in code. I am using TWSocket and I have created a bunch of generic logging code before so I will copy/paste/modify to get some data logging with DoDebugLog. The logging is only temporary. The problem. Using Wireshark the data from/to the sending and receiving computers match. The program works on W7 32 bit and 64 bit. The program works on W10 64 bit. The program has what appears to be data stream corruption issues on W10 32 bit. The data in Wireshark is correct. No development tools on W10 32 bit so I thought logging the stream from TWSocket.DataAvaliable would at least tell me the problem was before or after this event. All binary data and I am not using NativeInt. The packet size is < 200 bytes. Mark
×