USB Dongle Abfrage herstellen

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: USB Dongle Abfrage herstellen

Re: USB Dongle Abfrage herstellen

Post by Optimus Prime » 07 Aug 2020, 03:40

Dem kann ich mich an dieser Stelle nur noch anschließen. Großartige Community!!! Danke an alle Beteiligten :)

Re: USB Dongle Abfrage herstellen

Post by Gucky_87 » 06 Aug 2020, 05:02

Nicht der Rede wert, gern.

Ich habe das damals auch nur hinbekommen, weil ich von mehreren Leuten eine wirklich großartige Unterstützung bekommen habe.

Gucky.

Re: USB Dongle Abfrage herstellen

Post by Optimus Prime » 06 Aug 2020, 03:23

Hi just me und Gucky_87,

vielen Dank für die Infos und die Skripte. Es funktioniert nun so, wie es gedacht war.

@ Gucky_87
Es ist nat. der Demo-Authcode :)
Die Installerstory teste ich später aus...
Ich bin deiner Meinung, dass diese Sicherungsart mit Kanonen auf Spatzen schießt, um das Ziel zu erreichen. Das größte Sicherheitsrisiko geht von AHK aus ja, aber es funzt und wirkt sehr professionell ;) Einen Vorteil hat diese Variante jedoch und die sollte hier erwähnt werden: Die Software kann beliebig oft kopiert werden! Sie funktioniert jedoch nur mit einem geeigneten Dongle.
Ich bedanke mich vielmals bei euch für die Unterstützung und wünsche ein schönes Wochenende :D

Re: USB Dongle Abfrage herstellen

Post by Gucky_87 » 06 Aug 2020, 02:31

Hallöchen,

1)
Ich hoffe, dass Dein Auth Code nicht der echte Code ist. en Du von SG Lock bekommen hast.
Damit wäre jeglicher Schutz wirkungslos. Ist es der Democode, klappt der ausschließlich mit dem Demopaket.

2)
Die DLLs kopiere ich immer in das Verzeichnis, in dem sich das Sctipt befindet.
(Tipp: Pack die nachher mit Fileinstall ind das Scrit ein, dann werden wie automatsich 'installiert' und auch gefunden. An sich wird immer automatisch die richtige (32/64 Bit) Version geladen.

3)
Was Du genau schützen willst, also wohin Du welche Abfrage machst, liegt ganz bei Dir.
Willst Du nur einen einfache Schutz "Dongle da / nicht da", bau eine Abfrage ganz weit oben ins Scriptein, die dann z.B. die Seriennummer ausliest und, falls vorhanden (was nur bei korrekter Auth möglich ist), läuft Dein Programm. Andernfalls könntest Du eine Fehlermeldung generieren und das Script beenden.

4)
Je nachdem, welche Dongleversion Du hast (mit oder ohne Speicher, mit oder ohne Zähler, etc.)
könntest Du z.B. auch Zugriffe auf irgendetwas zähen. Deiner Phantasie sind da fast keine Grenzen gesetzt.

5)
Bedenke immer, dass Du AHK Script an sich gar nciht wirkungsvoll schützen kannst, da sie sehr leicht entpackt werden können und man dann den Quellcode wieder hat und somit das Dongle in 0.0 unwirksam machen kann ;)
Sicher, wer nciht weiß, dass es ein AHK Script ist, wird nicht weiter kommen, aber irgendwer kennt sich halt gut genug aus, um das feststellen zu können. Das INternet ist weeeit ;)

Gucky.

Re: USB Dongle Abfrage herstellen

Post by just me » 05 Aug 2020, 04:46

Moin,

vielleicht etwas in der Art (ungetestet):

Code: Select all

; ======================================================================================================================
; 2014/07 by Gucky
; This program shows how to use the SG-Lock together with AutoHotKey
; IMPORTANT NOTE:
; With the Demo Authent Key it´s impossible to read/write data from/to
; the memory or counter and/or to encrypt/decrypt data, because the
; demo locks (U2 type) don´t have any memory to store data.
; ======================================================================================================================
#NoEnv
SetBatchlines -1
#Include SglAuth.AHK
; This is the DEMO authentication code, every  regular SG-Lock user gets its own unique authentication code.
AuthentCode := [0xF574D17B, 0xA94628EE, 0xF2857A8F, 0x69346B4A
               ,0x4136E8F2, 0x89ADC688, 0x80C2C1D4, 0xA8C6327C
               ,0x1A72699A, 0x574B7CA0, 0x1E8D3E98, 0xD7DEFDC5]
SGL_Init()
; Search for a SG-Lock with a specified product id
ProductID := 1001
If !(SGL_Authent(AuthentCode) = 0)
   ExitMessage("SGL_Authent()`nERROR!`nDLL Authentification failed.")
If !(SGL_SearchLock(ProductID) = 0)
   ExitMessage("SGL_SearchLock()`nUnable to find SG-Lock`nwithproduct id: " . ProductID)
        MsgBox, 0, SGL_SearchLock(), Found SG-Lock with the`nproduct id: %ProductID%
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Hier Dein Skript!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; ======================================================================================================================
SGL_SearchLock(SGL_ProductID)
{
   Result := Return DllCall(SGLDLL . "\SglSearchLock", "UInt", SGL_ProductID)
   If (Result = 0)
      Return 0
   Else
      Return -%Result%
}
; ----------------------------------------------------------------------------------------------------------------------
ExitMessage(Msg)
{
   MsgBox, 16, , %Msg%
   ExitApp
}

Re: USB Dongle Abfrage herstellen

Post by Optimus Prime » 04 Aug 2020, 13:35

Hey just me, vielen vielen Dank für die Info. Habe den Text nun auch selbst gefunden...

Die Abfrage der ID und des AuthCodes funktionieren nun einwandfrei :D

Jetzt stellt sich mir hier nur die Frage, an welches Stelle ich nun ein bestehendes Skript einfügen kann, welches nach erfolgreicher Prüfung des Dongles ausgeführt wird...

Nachfolgend das verwendete Skript:

Code: Select all

; 2014/07 by Gucky
; This program shows how to use the SG-Lock together with AutoHotKey

; IMPORTANT NOTE:
; With the Demo Authent Key it´s impossible to read/write data from/to
; the memory or counter and/or to encrypt/decrypt data, because the
; demo locks (U2 type) don´t have any memory to store data.

#NoEnv
#Include SglAuth.AHK
SetBatchlines -1

; This is the DEMO authentication code, every  regular SG-Lock user gets its own unique authentication code.
AuthentCode := [0xF574D17B, 0xA94628EE, 0xF2857A8F, 0x69346B4A
               ,0x4136E8F2, 0x89ADC688, 0x80C2C1D4, 0xA8C6327C
               ,0x1A72699A, 0x574B7CA0, 0x1E8D3E98, 0xD7DEFDC5]

SGL_Init()

; Search for a SG-Lock with a specified product id
ProductID := 1001
If SGL_Authent(AuthentCode) = 0
    {
    If SGL_SearchLock(ProductID) = 0
        MsgBox, 0, SGL_SearchLock(), Found SG-Lock with the`nproduct id: %ProductID%
    else
        MsgBox, 0, SGL_SearchLock(), Unable to find SG-Lock`nwithproduct id: %ProductID%
    }
Else
    MsgBox, 0, SGL_Authent(), % "ERROR!`nDLL Authentification failed."
 
ExitApp    
    


SGL_SearchLock(SGL_ProductID)
    {
    Result := Return DllCall(SGLDLL . "\SglSearchLock", "UInt", SGL_ProductID)
    If Result = 0
        Return 0
    else
        Return -%Result%
    }
Wenn ich das Skript anstelle von

Code: Select all

  MsgBox, 0, SGL_SearchLock(), Found SG-Lock with the`nproduct id: %ProductID%
einsetze, wird das nachfolgende else als Fehler gefunden.
Wenn ich das Skript ans Ende setze, wird auch nichts ausgeführt.
Wie kann ich hier sinnvoll ein vorhandenes Skript installieren?
Hier ein Beispielskript:

Code: Select all

If WinExist(Adobe) && Winexist(Foxit) {
	MsgBox, Adobe Acrobat Reader und Foxit Reader sind gleichzeitig geöffnet! `nBitte eine Instanz beenden!
Return
}

;;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

If Winexist(Adobe)
{
	Gui, +OwnDialogs                                                                     ;; blockiert das AHK-Fenster während der Meldungs- bzw. Progress-Anzeige
	WinActivate, %Adobe%								;; aktiviert den (geöffneten) Adobe Acrobat Reader
	WinWaitActive, %Adobe%, , 3                                                    ;; wartet maximal 3 Sekunden auf die Aktivierung
	If (ErrorLevel) 
	{
		MsgBox, 16, Fehler!, Es wurde keine PDF-Datei gefunden!
	Return
	}
	send ^p 	                                                                       ;;Drucken
}

Re: USB Dongle Abfrage herstellen

Post by just me » 03 Aug 2020, 07:02

Moin,

wie es ist, sucht das Skript für AHK-64 nach einer SGLW64.DLL und für AHK-32 nach einer SGLW32.DLL. Auf 64-Bit-Systemen muss die SGLW64.DLL in den Ordner C:\Windows\System32. Für AHK-32 brauchst Du zusätzlich die SGLW32.DLL im Ordner C:\Windows\SysWOW64.

USB Dongle Abfrage herstellen

Post by Optimus Prime » 03 Aug 2020, 05:53

Hallo Zusammen,

auch ich bin auf die USB-Dongle von SG-Lock gestoßen und versuche mich gerade am Demo-Gerät, um mit AHK zu kommunizieren. Als Grundlage dienten die Infos aus dem Forum:https://www.autohotkey.com/boards/viewtopic.php?f=10&t=4130&hilit=sg+lock
Folgende Sachen habe ich unternommen:

- USB Dongle ID auf 1001 gesetzt
- AuthentCode an Dongle angepasst
- Datei "SglW32.dll" in C:\Windows\System32 gespeichert
- SglAuth.ahk im Quellordner gemäß Info Forum angelegt, Inhalt:

Code: Select all

; ======================================================================================================================

; Functions to use the SG-Lock (http://www.sg-lock.com/de/index.php) with AutoHotkey (http://www.autohotkey.com).
; This script must be included in the beginning inside the auto-execute-section of the programscript.
; It automatically detects to use the 32 or 64 bit SG-Lock Dll.
; The following routines are written by just me (2014/07) 
;======================================================================================================================

Global SGL_SUCCESS                  := 0x0000                               ; Error messages
     , SGL_DGL_NOT_FOUND            := 0x0001
     , SGL_LPT_BUSY                 := 0x0002
     , SGL_LPT_OPEN_ERROR           := 0x0003
     , SGL_NO_LPT_PORT_FOUND        := 0x0004
     , SGL_AUTHENTICATION_REQUIRED  := 0x0005
     , SGL_AUTHENTICATION_FAILED    := 0x0006
     , SGL_FUNCTION_NOT_SUPPORTED   := 0x0007
     , SGL_PARAMETER_INVALID        := 0x0008
     , SGL_SIGNATURE_INVALID        := 0x0009
     , SGL_USB_BUSY                 := 0x000A
     , SGLDLL := A_PtrSize = 8 ? "SGLW64.DLL" : "SGLW32.DLL"                ; Don´t change this!



; ======================================================================================================================
; Function:           Load dll
; Return values:
;     On success:     Handle of loaded dll file
;     On bad success: Errormessage and exit the program
; ======================================================================================================================

SGL_Init()
    {
    Static HMOD := 0
    If (HMOD = 0) && !(HMOD := DllCall("Kernel32.dll\LoadLibrary", "Str", SGLDLL, "UPtr"))
        {
        MsgBox, 16, ERROR!, `n'%SGLDLL%' not loaded!`nProgram will be terminated.
        ExitApp
        }
    Return HMOD
    }



; ======================================================================================================================
; Function:           Authentification between the script and the SglDLL.
; Parameters:
;     AuthentCode     Array with twelve 32 bit integers
; Return values:
;     On success:     0x0000 (SGL_SUCCESS)
;     On bad success: 0x0006 (SGL_AUTHENTICATION_FAILED)
; ======================================================================================================================

SGL_Authent(AuthentCode)
    {
    DllCall("msvcrt.dll\srand", "UInt", SGL_Rand())                         ; Init MSVCRT Random generator
    RandNumLo := SGL_Rand()                                                 ; Generate two random numbers
    RandNumHi := SGL_Rand()
    VarSetCapacity(RandNum, 8, 0)                                           ; Generate and fill Randnum
    NumPut(RandNumLo, RandNum, 0, "UInt")
    NumPut(RandNumHi, RandNum, 4, "UInt")
    VarSetCapacity(AppRandNum, 8, 0)                                        ; Generate AppRandNum and fill with 0
    NumPut(RandNumLo, AppRandNum, 0, "UInt")
    NumPut(RandNumHi, AppRandNum, 4, "UInt")
    VarSetCapacity(LibRandNum, 8, 0)                                        ; Generate LibRandNum and initialize it with 0
    VarSetCapacity(AuthentLocal, 32, 0)                                     ; Generate AuthentLocal and fill it with the first 8 values of the AuthentCode
    Addr := &AuthentLocal
    Loop, 8                                                                 ;Generate TeaKey and fill it with the last 4 values of the AuthentCode
        Addr := NumPut(AuthentCode[A_Index], Addr + 0, "UInt")
    TeaKey := [AuthentCode[9], AuthentCode[10], AuthentCode[11], AuthentCode[12]]
    RetCode := DllCall(SGLDLL . "\SglAuthentA", "Ptr", &AuthentLocal, "Ptr", &AppRandNum, "Ptr", &LibRandNum, "UInt") ; Call 'SglAuthentAÄ from Dll file
    If (RetCode <> SGL_SUCCESS)                                             ; Check result and exit on error.
        Return SGL_AUTHENTICATION_FAILED . ": SglAuthentA"
    SGL_TeaEncipher(RandNum, RandNum, TeaKey)                               ; Encrypt RandNum with TeaKey
    If (NumGet(RandNum, 0, "UInt") <> NumGet(AppRandNum, 0, "UInt"))        ; Check if the result conciders eith AppRandNum.
    || (NumGet(RandNum, 4, "UInt") <> NumGet(AppRandNum, 4, "UInt"))        ; If not, exit.
        Return SGL_AUTHENTICATION_FAILED . ": Sgl_TeaEncipher 1"
    SGL_TeaEncipher(LibRandNum, LibRandNum, TeaKey)                         ; Encrypt LibRandNum with TeaKey
    RetCode := DllCall(SGLDLL . "\SglAuthentB", "Ptr", &LibRandNum, "UInt") ; Call DLL function 'SglAuthentB'
    If (RetCode <> SGL_SUCCESS)                                             ; Check relult and exit on error
        Return SGL_AUTHENTICATION_FAILED . " - " . RetCode . " - " . ErrorLevel . " - SglAuthentB"
    Return SGL_SUCCESS                                                      ; Anything is all right
    }


; ======================================================================================================================
; Internal functions
; ======================================================================================================================

SGL_TeaEncipher(ByRef InData, ByRef OutData, ByRef Key)
    {
    Static Delta := 0x9E3779B9
    Y := NumGet(InData, 0, "UInt")                                          ; Initialize local vaiables
    Z := NumGet(InData, 4, "UInt")
    A := Key[1]
    B := Key[2]
    C := Key[3]
    D := Key[4]
    Sum := 0
    N := 32
    Loop, % N
        {                                                                   ; Encrypt
        Sum := SGL_UINT(Sum + Delta)
        Y := SGL_UINT(Y + (((Z << 4) + A) ^ (Z + Sum) ^ ((Z >> 5) + B)))
        Z := SGL_UINT(Z + (((Y << 4) + C) ^ (Y + Sum) ^ ((Y >> 5) + D)))
        }
    NumPut(Y, OutData, 0, "UInt")                                           ; Write result to OutData
    NumPut(Z, OutData, 4, "UInt")
    }



; ----------------------------------------------------------------------------------------------------------------------
SGL_Rand()
    {
    Return ((DllCall("msvcrt.dll\rand", "Int") << 16) | DllCall("msvcrt.dll\rand", "Int")) & 0xFFFFFFFF
    }



; ----------------------------------------------------------------------------------------------------------------------
SGL_UINT(Value)
    {
    Return (Value & 0xFFFFFFFF)
    }
; ======================================================================================================================
- Datei "Spielwiese.ahk" angelegt und folgenden Inhalt aus Forum eingefügt:

Code: Select all

; 2014/07 by Gucky
; This program shows how to use the SG-Lock together with AutoHotKey

; IMPORTANT NOTE:
; With the Demo Authent Key it´s impossible to read/write data from/to
; the memory or counter and/or to encrypt/decrypt data, because the
; demo locks (U2 type) don´t have any memory to store data.

#NoEnv
#Include SglAuth.AHK
SetBatchlines -1

; This is the DEMO authentication code, every  regular SG-Lock user gets its own unique authentication code.
AuthentCode := [0xF574D17B, 0xA94628EE, 0xF2857A8F, 0x69346B4A
               ,0x4136E8F2, 0x89ADC688, 0x80C2C1D4, 0xA8C6327C
               ,0x1A72699A, 0x574B7CA0, 0x1E8D3E98, 0xD7DEFDC5]

SGL_Init()

; Search for a SG-Lock with a specified product id
ProductID := 1001
If SGL_Authent(AuthentCode) = 0
    {
    If SGL_SearchLock(ProductID) = 0
        MsgBox, 0, SGL_SearchLock(), Found SG-Lock with the`nproduct id: %ProductID%
    else
        MsgBox, 0, SGL_SearchLock(), Unable to find SG-Lock`nwithproduct id: %ProductID%
    }
Else
    MsgBox, 0, SGL_Authent(), % "ERROR!`nDLL Authentification failed."
 
ExitApp    
    


SGL_SearchLock(SGL_ProductID)
    {
    Result := Return DllCall(SGLDLL . "\SglSearchLock", "UInt", SGL_ProductID)
    If Result = 0
        Return 0
    else
        Return -%Result%
    }

Diese Funktion sollte nun den Dongle suchen.
Egal wie ich an die Geschichte herangehe (AHK A32, AHK U32, AHKU64, diverse Skriptversuche...),
ich komme immer bei dem folgenden Fehler heraus:
Scheinbar ist die Kommunikation zur SGLW32.dll fehlerhaft und ich weiß nicht wie ich dieses Thema beheben kann.
Kann jemand hier weiterhelfen oder weiß noch Rat. Ich weiß das verhergehende Thema ist sehr sehr alt :) Umso mehr freue ich mich über euer Feedback...
Attachments
Fehler AHK.JPG
Fehler AHK.JPG (8.8 KiB) Viewed 8855 times

Top