FengHuangWuShen Posted August 24, 2016 Share Posted August 24, 2016 Just to start off, this isn't a project or collaboration of any kind, I was unable to start a topic in the 'Example Scripts' section. This is just a small utility program I made for something I needed years ago, but only recently coded it in AutoIt. Basically it is a one way Encrypter / Decrypter for XOR. Nothing much to it; enter a HEX string and hit the button, it will return a result using the key that you input into the box. Not sure if anyone has done it this way before, but it works great, and I got all the kinks worked out finally. Let me know what you all think, and if there are any improvements that can be made, whether it be with the GUI or the efficiency of my code. Additionally, if possible, move this thread to the correct section. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\..\Desktop\ENDEC.ico #AutoIt3Wrapper_Outfile=ENDEC.Exe #AutoIt3Wrapper_Res_Description=One way XOR Encrypt / Decrypt #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $XOR_GUI = GUICreate("XOR En/Decrypt", 615, 290, 192, 124) $CRYPT_BTN = GUICtrlCreateButton("En/Decrypt", 505, 32, 100, 25) $CLIP_BTN = GUICtrlCreateButton("Copy", 505, 163, 100, 25) $CLEAR_BTN = GUICtrlCreateButton("Clear", 505, 215, 100, 25) $XOR_KEY = GUICtrlCreateInput("61", 535, 100, 50, 15, BitOR($ES_UPPERCASE, $ES_CENTER), 0) $STR_INPUT = GUICtrlCreateEdit("", 24, 32, 469, 105, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_UPPERCASE, $ES_MULTILINE), 0) $STR_RESULT = GUICtrlCreateEdit("", 24, 163, 469, 105, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_UPPERCASE, $ES_READONLY), 0) GUICtrlSetColor($STR_RESULT, $COLOR_RED) $XOR_KEY_LABEL = GUICtrlCreateLabel("En/Decrypt Key", 517, 80, 100, 17) $STR_INPUT_LABEL = GUICtrlCreateLabel("String [ HEX ] 0", 24, 8, 200, 17) $STR_RESULT_LABEL = GUICtrlCreateLabel("Result [ HEX ] 0", 24, 144, 200, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $STR_DATA = [''] While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $CRYPT_BTN Convert() Case $CLIP_BTN ClipPut(GUICtrlRead($STR_RESULT)) Case $CLEAR_BTN Clear() EndSwitch WEnd Func Convert() GUICtrlSetData($STR_INPUT_LABEL, 'String [ HEX ] ' & StringLen(GUICtrlRead($STR_INPUT))) $STR_READ = '0x' & StringStripWS(GUICtrlRead($STR_INPUT), 8) Dim $STR_DATA = [''] For $i = 1 To StringLen($STR_READ) Step 2 If StringLen(GUICtrlRead($STR_INPUT)) > 0 Then $STR_TRIM = '0x' & StringMid($STR_READ, $i, 2) $XOR_STR = BitXOR($STR_TRIM, '0x' & GUICtrlRead($XOR_KEY)) _ArrayAdd($STR_DATA, StringMid(Hex($XOR_STR), 7, 2)) Else ContinueLoop Dim $STR_DATA = [''] EndIf Next If StringLen(GUICtrlRead($STR_INPUT)) > 0 Then $STR_PARSE = _ArrayToString($STR_DATA, ' ', 2, UBound($STR_DATA) -1) GUICtrlSetData($STR_RESULT, $STR_PARSE) GUICtrlSetData($STR_RESULT_LABEL, 'Result [ HEX ] ' & StringLen(GUICtrlRead($STR_RESULT))) Else MsgBox(48, 'ERROR', @error & ' There is no data to parse.') Clear() EndIf EndFunc Func Clear() GUICtrlSetData($STR_INPUT, '') GUICtrlSetData($STR_INPUT_LABEL, 'String [ HEX ] 0') GUICtrlSetData($STR_RESULT, '') GUICtrlSetData($STR_RESULT_LABEL, 'Result [ HEX ] 0') Dim $STR_DATA = [''] EndFunc TO-DO: Restrict the input box to only accept HEX and Numeric values. Download: ENCDEC.Src.au3 ENDEC.ico Link to comment Share on other sites More sharing options...
jchd Posted August 24, 2016 Share Posted August 24, 2016 If your OTP (One Time Pad) is shorter than the plaintext (the unencrypted input) then it's terribly unsafe. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted August 24, 2016 Author Share Posted August 24, 2016 Yes, It is terribly unsafe and weak. I'm not too familiar with encryption though. This was just a small application I was working on as a tool for something I used to do years ago. It was for packet analysis back around ... 2006 or so. It's rather useless to me now, since I don't work with that anymore, but it was still fun to get it working. Link to comment Share on other sites More sharing options...
jchd Posted August 24, 2016 Share Posted August 24, 2016 My remark was merely a warning to unsuspecting future readers of this post. Decrypting text XORed with a 1-byte key is sister kid level homework argumentum and FengHuangWuShen 2 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted August 24, 2016 Author Share Posted August 24, 2016 It's also very easy to crack if you have the encrypted data in front of you haha. Just look for repeated 1-byte, and that is most likely the key Link to comment Share on other sites More sharing options...
spudw2k Posted August 24, 2016 Share Posted August 24, 2016 What do you mean by one way? If it's decryptable, it isn't one-way in the traditional encryption sense. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted August 24, 2016 Author Share Posted August 24, 2016 Well I don't know the "traditional encryption sense", but I get what ya mean I meant one way as in 1 simple key to both encrypt and decrypt; no need to follow any other steps to achieve the following. Link to comment Share on other sites More sharing options...
spudw2k Posted August 25, 2016 Share Posted August 25, 2016 Ah. Understood For most intents and purposes (in the traditional encryption sense), "one way" means one direction...meaning encrypt only. Hashing algorithms for example (MD5, SHA, etc.) do one way encryption. to produce the hash value. The method used to generate the hash value should be very difficult to reverse. If you are interested in encryption I'd highly recommend looking at the _Crypt* functions in the help file. Either way, keep on scriptin' FengHuangWuShen 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now