Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/18/2015 in all areas

  1. CodeCrypter enables you to encrypt scripts without placing the key inside the script. This is because this key is extracted from the user environment at runtime by, for example: password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here): Latest version: 3.4 (3 Dec 2021): please follow this link. Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly. How the bits and pieces fit together: CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here: '?do=embed' frameborder='0' data-embedContent>> The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init(). From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely: In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really. Not convinced? Check out: a simple HowTo Guide: HowToCodeCrypt.pdf an updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:CodeCrypterFAQ.pdf For additional explanations/examples in response to specific questions by forum members (how it works, what it can/cannot do), see elsewhere in this thread, notably: Simple analogy of how it works: post #53, second part General Explanation and HowTo: post #9, 51, 75, 185/187, 196, 207, 270, 280 (this gets a bit repetitive) BackTranslation: post #179 Obfuscation: post #36 (general), 49 (selective obfuscation) Specific features and fixes: post #3 (security), 84 (redefining the expected runtime response), 169 (Curl Enum fix), 185/187 (using license keys), 194 (replacing Ward's AES UDF with different encryption/decryption calls), 251 (AV detection issue), 262 (extract key contents to USB on different target machine prior to encryption) Limitations: post #26 (@error/@extended), 149 (FileInstall), 191 (AES.au3 on x64) Not recommended: post #46/249 (static encryption), 102 (programme logic error), 237 (parsing password via cmdline) Technical notes: BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want). CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples. Encryption currently relies on Ward's excellent AES UDF and TheXman's sophisticated CryptoNG bundle. You can replace these with any other algorithm you like (but this is not trivial to do: edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry(), see post #194 in this thread). AES by Ward, and CryptoNG by TheXman are also included in the bundle (with many thanks to Ward and TheXman for graciously allowing me to republish their outstanding work). Going to lie down now... RT
    1 point
  2. Hi guys/girls! I'm gonna share this UDF I made today. It allows you to easily create TCP servers and set actions depending on three events: OnConnect, OnDisconnect and OnReceive. It is also multi client (you can set the clients limit) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create your TCP server and don't want to mix it with the TCP functions. Also, as it runs on background just firing events, it won't pause your script while listening/receiving, so you can do anything else (stop and restart the server, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired. It's also very easy to use. See this examples: Example #1: A basic server By running this (then connecting to the server using Netcat), you will receive a message box telling you when some user connects or disconnects (the socket ID and his IP address is passed as parameter to your callback function) and also when the user sends something over the TCP socket (the data sent is passed as parameter). #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" ; First we set the callback functions for the three events (none of them is mandatory) _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") ; And some parameters _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) ; Finally we start the server at port 8081 at any interface _TCPServer_Start(8081) Func connected($iSocket, $sIP) MsgBox(0, "Client connected", "Client " & $sIP & " connected!") _TCPServer_Broadcast('new client connected guys', $iSocket) _TCPServer_Send($iSocket, "Hey! Write something ;)" & @CRLF) _TCPServer_SetParam($iSocket, "will write") EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPServer_Send($iSocket, "You wrote: " & $sData) _TCPServer_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEnd Example #2: A basic HTTP server (just one page, as it is just an example) In this example, we run this code and point our browser to the address mentioned on the comments. A basic "It works!" page is show. #cs Run this script Point your browser to http://localhost:8081/ #ce #include "TCPServer.au3" _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func received($iSocket, $sIP, $sData, $sParam) _TCPServer_Send($iSocket, "HTTP/1.0 200 OK" & @CRLF & _ "Content-Type: text/html" & @CRLF & @CRLF & _ "<h1>It works!</h1>" & @CRLF & _ "<p>This is the default web page for this server.</p>" & @CRLF & _ "<p>However this server is just a 26-lines example.</p>") _TCPServer_Close($iSocket) EndFunc ;==>received While 1 Sleep(100) WEnd Example #3: A telnet-like server (Command Prompt bound to the socket after password requesting) By running this example and connecting with Netcat, we will be asked for a password, which is 12345 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example). #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" Global $sPassword = "12345" ; input server password here _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func connected($iSocket, $sIP) _TCPServer_Send($iSocket, "Welcome! Please input password: ") _TCPServer_SetParam($iSocket, 'login') EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sParam) If $sParam = "login" Then If $sData <> $sPassword Then _TCPServer_Send($iSocket, "Wrong password. Try again: ") Return Else _TCPServer_SetParam($iSocket, 'command') _TCPServer_BindAppToSocket($iSocket, 'cmd.exe') EndIf ElseIf $sParam = "command" Then _TCPServer_SendToBound($iSocket, $sData) EndIf EndFunc ;==>received While 1 Sleep(100) WEnd The limit is your imagination? Well, no sure. We have this limit: You can't create more than one server with this UDF in the same script. However, you can pause and resume (read 'stop and start again') your server at any time in your script, without having to reset the server settings. And of course you can have many clients (or just one, it's your choice!) in the same server. Or run multiple instances.Functions list: _TCPServer_Start _TCPServer_Stop _TCPServer_Close _TCPServer_Send _TCPServer_Broadcast _TCPServer_SetParam _TCPServer_BindAppToSocket _TCPServer_SendToBound _TCPServer_UnBindAppToSocket _TCPServer_GetMaxClients _TCPServer_IsServerActive _TCPServer_ListClients _TCPServer_OnConnect _TCPServer_OnDisconnect _TCPServer_OnReceive _TCPServer_SetMaxClients _TCPServer_DebugMode _TCPServer_AutoTrim _TCPServer_SocketToIP _TCPServer_SocketToConnID _TCPServer_ConnIDToSocket Help file and more examples included! Latest version: 1.0.0.1 Download: TCPServer UDF.rar Changelog 1.0 - First release - 18/04/20151.0.0.1 - Bug fix __TCPServer_Accept internal function / help file recompiled - 26/04/2015Perhaps you will need to uncompress the file first, so the help file will work. Fork this on Github: http://github.com/jesobreira/TCPServerUDF TCPServer UDF.rar
    1 point
  3. OK I understand What about this one ? #include <GuiConstantsEx.au3> #include <Windowsconstants.au3> #include <SendMessage.au3> HotKeySet("{ESC}", "On_Exit") ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Set max and min GUI sizes Global Const $iGUIMinX = 50, $iGUIMinY = 50, $iGUIMaxX = 300, $iGUIMaxY = 300 Global $tPoint = DllStructCreate("struct; long X;long Y; endstruct") ; Create GUI $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP) GUISetBkColor(0x00FF00) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize/drag GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits While 1 Sleep(10) WEnd ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Local $iCursorType = _GetBorder() If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf EndFunc ;==>WM_LBUTTONDOWN ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() DllStructSetData($tPoint, "x", MouseGetPos(0)) DllStructSetData($tPoint, "y", MouseGetPos(1)) Local $aResult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tPoint) If $aResult[0] <> $hGUI Then Return Local $iCursorID Switch _GetBorder() Case 0 $iCursorID = 2 ; arrow Case 1, 2 $iCursorID = 13 ; SIZEWE Case 3, 6 $iCursorID = 11 ; SIZENS Case 5, 7 $iCursorID = 10 ; SIZENESW Case 4, 8 $iCursorID = 12 ; SIZENWSE EndSwitch GUISetCursor($iCursorID, 1) EndFunc ;==>SetCursor ; Determines if mouse cursor over a border Func _GetBorder() Local $aMPos = MouseGetPos() Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 Local $iTopBot = 0 If $aMPos[0] < $aWinPos[0] + $iMargin Then $iSide = 1 If $aMPos[0] > $aWinPos[0] + $aWinPos[2] - $iMargin Then $iSide = 2 If $aMPos[1] < $aWinPos[1] + $iMargin Then $iTopBot = 3 If $aMPos[1] > $aWinPos[1] + $aWinPos[3] - $iMargin Then $iTopBot = 6 Return $iSide + $iTopBot EndFunc ;==>_GetBorder ; Set min and max GUI sizes Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tMinMaxInfo, 7, $iGUIMinX) DllStructSetData($tMinMaxInfo, 8, $iGUIMinY) DllStructSetData($tMinMaxInfo, 9, $iGUIMaxX) DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY) Return 0 EndFunc ;==>_WM_GETMINMAXINFO Func On_Exit() Exit EndFunc
    1 point
  4. passwd, Welcome to the AutoIt forums. You need to put the Random line inside the loop - at the moment you are overwriting the same file all the time. M23
    1 point
  5. Please read title="Forum Rules">Forum Rules
    1 point
  6. But you still read the file as text, not binary!
    1 point
  7. You need to use binary mode for the file. Also you better convert both key and data to UTF8 else non-ANSI characters will get emasculated.
    1 point
  8. Melba23

    inetget

    hasan11, I see you have deleted the OP of every thread you have made here - this is unacceptable, as it prevents anyone else benefiting from the thread when searching the forum. As you seem so keen to hide your queries, I must begin to question why you are asking them in the first place. So I think we will lock this thread and put you on Moderator queue to check on what you are asking in future before allowing the threads to appear. M23
    1 point
  9. Zedna

    change language?

    NO. YES.
    1 point
  10. Hi guinness, Thanks for the clarification. Funny thing, serendipity. A few days ago somebody else just PM'ed me with a similar request, to produce a cmdline utility of CodeCrypter (the main front-end for this library) to just spit out an obfuscated and/or encrypted version of any input script. When I have a spare moment, I'll probably be able to rustle something up... As far as engaging directly with the MCF library (and presuming you studied the Tutorial), CodeCrypter's source is admittedly a complicated example (although it does more or less exactly what you request, see the presets Tab). The problem is that the process is intrinsically multi-step; you have to run CodeScanner first to produce the MCF relevant arrays, which you can then engage with, through CodeCrypter, your own script, or both. The basic idea is however, really simple: split the contents of your script up in topical arrays, turning the original script into a collection of placeholder array pointers duplicate the arrays you wish to change the content of, and make whatever changes you like there rebuild the script using the metacode pointers, but referring to the new arrays Codescanner does step 1 for you, whereas CodeCrypter provides examples of steps 2 and 3. Alternatively you can write your own script to change the *New content arrays, and then simply use CodeCrypter's "Create New" option to rebuild. It's potentially very powerful, because you can also make structural changes in the metacode file itself prior to step 3. In encryption, for example, I replace every function call, macro and conditional with an Execute(<decrypt><string>) wrapper. It's like the ultimate search-and-replace engine for both content and structure, but separately. But you're right, it probably looks forbidding, but it is surprisingly difficult to produce a simple in/out example. I'll have to think about how I might be able to make this library more accessible. Beng the designer is a handicap in this case, because I have to place myself in the shoes of somebody who sees the MCF UDFs for the first time, and it's hard to wipe once's subconscious mindset. Anyway, your input is much appreciated.
    1 point
×
×
  • Create New...