Jump to content

Mark-

Members
  • Content Count

    208
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Mark-


  1. Hello,

     

    I will control both ends of the data pipe and payload. A customer has informed me a proxy is used. Never used a proxy so scoping out what requires attention for success.

     

    From the server end it appears nothing to do. Perhaps that is wrong.

     

    For the client end I see:
    ProxyAuth, select one of the options.
    ProxyPassword, a password if ProxyAuth is other than httpAuthNone.
    ProxyUername, a username if ProxyAuth is other than httpAuthNone.
    ProxyPort, the port of the proxy server.

     

    Proxy, seems to be the IP address or host name.
    ProxyConnection, seems to be a keep-alive setting, not sure
    ProxyURL, not sure perhaps can specify all needed properties in one url string.

     

    The last three, not sure what to do with them.

    Any documents I can read or anyone shed some light?

     

    Thanks,

     

    Mark

     


  2. 21 hours ago, aehimself said:

    Don't rely on the registry, it easily can be overwritten!

    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. 1 hour ago, FredS said:

    The line with 'isWin8' is required and correct and the line following with 'data[66]' should only be executed if isWin8=true.

    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'

     


  4. 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.

     


  5. 7 hours ago, FPiette said:

    The component doesn't do that by itself but has a property to select the port to listen to. So just assign it to the value you need before calling start.

     

    Please note that the client must know the port to connect so I don't understand why you want a random port! Unless you used the term "random" instead of "custom".

    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.


  6. 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

     

     


  7. 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


  8. 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

     


  9. 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.

     


  10. 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

×