Sign in to follow this  
Followers 0
Skrip

Corruption

16 posts in this topic

Alright, I've been working on this program that allows me to corrupt files. (It's not done yet) It's intention is for viruses (to help remove them).

But it's not working $search ALWAYS comes up with -1, then on the second time around it just comes up blank. With no errors.

I don't understand why this doesn't work.

Okay. It opens the folder - looks for the *.$input

#include <GUIConstants.au3>
#include <File.au3>
#include <String.au3>
Global $msgbo
$stop = 0
$go = 1
$moveon = 0
$moveon_2 = 1
$moveon_3 = 0
$i = 0
$random1 = 0
$random2 = 0
Dim $time_dif
$time_dif_r = 0
Dim $time_start
$pause = 0
    $go = 1
    $S_Form1 = GUICreate("Search to Kill", 635, 176, 193, 115)
    $S_Input1 = GUICtrlCreateInput("C:\", 64, 16, 465, 21)
    $S_Label1 = GUICtrlCreateLabel("Address:", 16, 16, 45, 17)
    $S_Browse = GUICtrlCreateButton("Browse", 536, 16, 73, 17, 0)
    $S_Label2 = GUICtrlCreateLabel("Number of lines to corrupt:", 16, 48, 128, 17)
    $S_Input2 = GUICtrlCreateInput("1000", 144, 48, 65, 21)
    $S_Label3 = GUICtrlCreateLabel("File extension to search for:", 16, 80, 133, 17)
    $S_Input3 = GUICtrlCreateInput(".txt", 152, 80, 73, 21)
    $Group1 = GUICtrlCreateGroup("Corruption Status", 248, 48, 337, 121)
    $S_label4 = GUICtrlCreateLabel("Searching for: ", 264, 72, 145, 17)
    $S_Label5 = GUICtrlCreateLabel("Found:", 264, 96, 145, 17)
    $S_Label6 = GUICtrlCreateLabel("Corrupting:", 264, 120, 55, 17)
    $S_Label7 = GUICtrlCreateLabel("Time:", 416, 72, 145, 17)
    $S_Label8 = GUICtrlCreateLabel("Completed: 0 Files", 416, 96, 145, 17)
    $S_Label9 = GUICtrlCreateLabel(" The corruption can only be aported from CTRL+ALT+DEL ", 280, 144, 283, 17, BitOR($SS_SUNKEN, $WS_BORDER))
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $S_Label10 = GUICtrlCreateLabel(" OFF ", 320, 120, 30, 17, $SS_SUNKEN)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $S_Button1 = GUICtrlCreateButton("Corrupt", 64, 128, 129, 25, 0)
    GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
    $S_Checkbox1 = GUICtrlCreateCheckbox("Destory File | Erase -> Corrupt", 16, 104, 169, 17)
    GUISetState(@SW_SHOW)

    While 1
        $Msg = GUIGetMsg()
        Select
            Case $Msg = $GUI_EVENT_CLOSE
                Exit
                
            Case $Msg = $S_Browse
                $file_browse = FileSelectFolder("Select a Folder", "", 4)
                If @error Then
                    MsgBox(48, "Error", "The program has encountered an error. Please select a different folder, or restart the program.")
                Else
                    GUICtrlSetData($S_Input1, $file_browse)
                EndIf
                
            Case $Msg = $S_Button1
                $searching = 1
                $moveon_2 = 1
                GUICtrlSetData($S_label4, "Searching for: " & GUICtrlRead($S_Input3))
                GUICtrlSetData($S_Label10, " ON ")
                GUICtrlSetBkColor($S_Label10, 0xFF0000)
                $lines = GUICtrlRead($S_Input2)
                While $searching = 1
                    If $go = 1 Then
                        $search = FileFindFirstFile("*." & $S_Input3)
                        $go = 0
                    Else
                        $search = FileFindNextFile($search)
                    EndIf
                    GUICtrlSetData($S_Label5, $search)
                    MsgBox(0, "", $search)
                    If FileExists($search) Then
                        $moveon = 1
                    Else
                        $moveon = 0
                    EndIf
                    If Not StringIsDigit($S_Input2) Then
                        MsgBox(48, "Error", "You need a number in the 'lines' input box, to continue.")
                        $moveon_2 = 0
                    EndIf
                    If $moveon = 1 And $moveon_2 = 1 Then
                        $file = FileOpen($search, 1)
                        If @error Then
                            MsgBox(48, "Error", "The program has encountered an error. Error #004 at" & @error)
                            Exit
                        EndIf
                        If GUICtrlRead($S_Checkbox1) = 1 Then
                            FileClose($file)
                            $file = FileOpen($search, 2)
                        EndIf
                        $time_start = TimerInit()
                        Do
;~                  _StopCheck(1)
;~                  ControlEnable("Corruptor", "", $Button1)
;~                  ControlEnable("Corruptor", "", $Button2)
;~                  ControlEnable("Corruptor", "", $Input1)
;~                  ControlEnable("Corruptor", "", $Input2)
;~                  ControlEnable("Corruptor", "", $Label1)
;~                  ControlDisable("Corruptor", "", $Button3)
                            $time_dif = TimerDiff($time_start)
                            $time_dif_r = Round($time_dif / 1000, 2)
                            $random1 = Random(1, _FileCountLines($search) + 1, 1)
                            $random2 = Random(1, 5000000000, 1)
                            FileWrite($file, _StringToHex($random2))
                            _FileWriteToLine($file, Random(1, 10) + 1, _StringToHex($random2), 0)
                            If @error < 0 Then
                                $msgbo = MsgBox(4, "Error - " & @error, "We have encountered an error while corrupting the file. The program will be forced to exit." & @CRLF & "Erase file contents?")
                                If $msgbo = 6 Then
                                    FileClose($file)
                                    $file = FileOpen($search, 2)
                                    MsgBox(0, "Complete", "Contents erased. Program exiting.", 3)
                                    $i = $lines
                                    Exit
                                Else
                                    $i = $lines
                                    Exit
                                EndIf
                            EndIf
                            GUICtrlSetData($S_Label7, "Time: " & $time_dif_r & " Seconds")
                            $i = $i + 1
                        Until $i = $lines + 1
                        $i = 0
                        FileClose($file)
                    EndIf
                WEnd
        EndSelect
    WEnd

Sorry for the unnessary vars on the top. Some are needed here, others are needed in a different part of the script..


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe

While $searching = 1
                    If $go = 1 Then
                        $Find = FileFindFirstFile("*." & $S_Input3)
                        $go = 0
                    Else
                        $search = FileFindNextFile($Find)
                    EndIf
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That didn't fix it. It didn't even find the file now..

I saw what you were trying to do though.

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Fixed everything(nearly), execpt for some reason it is not writing to the files...UNLESS it looks in the script directory.

$lines = 0
    $S_Form1 = GUICreate("Search to Kill", 635, 176, 193, 115)
    $S_Input1 = GUICtrlCreateInput("C:\", 64, 16, 465, 21)
    $S_Label1 = GUICtrlCreateLabel("Address:", 16, 16, 45, 17)
    $S_Browse = GUICtrlCreateButton("Browse", 536, 16, 73, 17, 0)
    $S_Label2 = GUICtrlCreateLabel("Number of lines to corrupt:", 16, 48, 128, 17)
    $S_Input2 = GUICtrlCreateInput("100", 144, 48, 65, 21)
    $S_Label3 = GUICtrlCreateLabel("File extension to search for:", 16, 80, 133, 17)
    $S_Input3 = GUICtrlCreateInput("txt", 152, 80, 73, 21)
    $Group1 = GUICtrlCreateGroup("Corruption Status", 248, 48, 337, 121)
    $S_label4 = GUICtrlCreateLabel("Searching for: ", 264, 72, 145, 17)
    $S_Label5 = GUICtrlCreateLabel("Found:", 264, 96, 145, 17)
    $S_Label6 = GUICtrlCreateLabel("Corrupting:", 264, 120, 55, 17)
    $S_Label7 = GUICtrlCreateLabel("Time:", 416, 72, 145, 17)
    $S_Label8 = GUICtrlCreateLabel("Completed: 0 Files", 416, 96, 145, 17)
    $S_Label11 = GUICtrlCreateLabel("Line: " & $lines & " of " & GUICtrlRead($S_Input2), 416, 118, 145, 17)
    $S_Label9 = GUICtrlCreateLabel(" The corruption can only be aported from CTRL+ALT+DEL ", 280, 144, 283, 17, BitOR($SS_SUNKEN, $WS_BORDER))
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $S_Label10 = GUICtrlCreateLabel(" OFF ", 320, 120, 30, 17, $SS_SUNKEN)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $S_Button1 = GUICtrlCreateButton("Corrupt", 64, 128, 129, 25, 0)
    GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
    $S_Button2 = GUICtrlCreateButton("Single File Corrupt", 60, 155, 137, 17)
    $S_Checkbox1 = GUICtrlCreateCheckbox("Destory File | Erase -> Corrupt", 16, 104, 169, 17)
    GUISetState(@SW_SHOW)

    While 1
        $Msg = GUIGetMsg()
        Select
            Case $Msg = $GUI_EVENT_CLOSE
                Exit
                
            Case $Msg = $S_Browse
                $file_browse = FileSelectFolder("Select a Folder", "", 4)
                If @error Then
                    MsgBox(48, "Error", "The program has encountered an error. Please select a different folder, or restart the program.")
                Else
                    GUICtrlSetData($S_Input1, $file_browse & "\")
                EndIf
                
            Case $Msg = $S_Button1
                $searching = 1
                $search = 1
                $moveon_2 = 1
                $go = 1
                $count = 0
                $i = 0
                GUICtrlSetData($S_label4, "Searching for: " & GUICtrlRead("." & $S_Input3))
                GUICtrlSetData($S_Label10, " ON ")
                GUICtrlSetBkColor($S_Label10, 0xFF0000)
                $lines = GUICtrlRead($S_Input2)
                GUICtrlSetData($S_Label11, "Line: 0 of " & GUICtrlRead($S_Input2))
                While $searching = 1
                    If $go = 1 Then
                        $Find = FileFindFirstFile(GUICtrlRead($S_Input1) & "\" & "*." & GUICtrlRead($S_Input3))
                        $search = $Find
                        $go = 0
                    Else
                        $search = FileFindNextFile($Find)
                        $count = $count + 1
                        GUICtrlSetData($S_Label8, "Completed: " & $count & " Files")
                    EndIf
                    If $search = -1 Then
                        MsgBox(0, "Error", "The program has encountered a '-1' error at #005." & @CRLF & "This most likely means, that it could not find the desired file in the folder." & @CRLF & "You search for: *." & GUICtrlRead($S_Input3))
                    EndIf
                    If $search = "" Then
                        MsgBox(0, "", "Corruption Completed")
                        $searching = 0
                        GUICtrlSetData($S_label4, "Searching for: ")
                        GUICtrlSetData($S_Label10, " OFF ")
                        GUICtrlSetBkColor($S_Label10, 0x00FF00)
                    EndIf
                    GUICtrlSetData($S_Label5, "Found: " & $search)
                    If FileExists($search) Then
                        $moveon = 1
                    Else
                        $moveon = 0
                    EndIf
                    If Not StringIsDigit($S_Input2) Then
                        MsgBox(48, "Error", "You need a number in the 'lines' input box, to continue.")
                        $moveon_2 = 0
                    EndIf
                    If $moveon = 1 And $moveon_2 = 1 Then
                        $file = FileOpen(GUICtrlRead($S_Input1) & "\" & $search, 1)
                        If @error Then
                            MsgBox(48, "Error", "The program has encountered an error. Error #006 at" & @error)
                            Exit
                        EndIf
                        If GUICtrlRead($S_Checkbox1) = 1 Then
                            FileClose($file)
                            $file = FileOpen(GUICtrlRead($S_Input1) & "\" & $search, 2)
                        EndIf
                        $time_start = TimerInit()
                        Do
;~                  _StopCheck(1)
;~                  ControlEnable("Corruptor", "", $Button1)
;~                  ControlEnable("Corruptor", "", $Button2)
;~                  ControlEnable("Corruptor", "", $Input1)
;~                  ControlEnable("Corruptor", "", $Input2)
;~                  ControlEnable("Corruptor", "", $Label1)
;~                  ControlDisable("Corruptor", "", $Button3)
                            $time_dif = TimerDiff($time_start)
                            $time_dif_r = Round($time_dif / 1000, 2)
                            $random1 = Random(1, _FileCountLines($search) + 1, 1)
                            $random2 = Random(1, 5000000000, 1)
                            FileWrite($file, _StringToHex($random2))
                            _FileWriteToLine($file, Random(1, 10) + 1, _StringToHex($random2), 0)
                            If @error < 0 Then
                                $msgbo = MsgBox(4, "Error - " & @error, "We have encountered an error while corrupting the file. The program will be forced to exit." & @CRLF & "Erase file contents?")
                                If $msgbo = 6 Then
                                    FileClose($file)
                                    $file = FileOpen($search, 2)
                                    MsgBox(0, "Complete", "Contents erased. Program exiting.", 3)
                                    $i = $lines
                                    Exit
                                Else
                                    $i = $lines
                                    Exit
                                EndIf
                            EndIf
                            GUICtrlSetData($S_Label7, "Time: " & $time_dif_r & " Seconds")
                            $i = $i + 1
                            GUICtrlSetData($S_Label11, "Line: " & $i & " of " & GUICtrlRead($S_Input2))
                        Until $i = $lines + 1
                        $i = 0
                        FileClose($file)
                    EndIf
                WEnd
            Case $Msg = $S_Button2
                GUIDelete($S_Form1)
                Main()
        EndSelect
    WEnd
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Help, please? This is probably a noob mistake. But i'm still not getting this working.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You should just have a function that you pass a file path to and it will write zeros / random characters. You would be better off allowing the end user to decide which file search function to use.

Something like this just seems simpler:

$result = WriteZerosToFile(@DesktopDir & "\FileZilla_2_2_32_setup.exe")

Func WriteZerosToFile($WZTFpath)
    
    ;Verify file exists
    If NOT FileExists($WZTFpath) Then Return SetError(1,0,0)
    
    ;Store filesize
    $WZTFbytes = FileGetSize($WZTFpath)
    
    ;Delete file
    If NOT FileDelete ($WZTFpath) Then Return SetError(1,0,0)
    
    $WZTFhandle = FileOpen ($WZTFpath, 2)
    
    ;Write one character for every byte
    For $X = 1 to $WZTFbytes
        FileWrite($WZTFhandle, 0)
    Next
    
    Return 1
EndFunc

I could use FileListToArrayEx to find everything matching a filter and loop through that array to hit every file.

Edited by weaponx

Share this post


Link to post
Share on other sites

Hmm, everything is already done. I can put that in later.

The only problem, is that it only affects files, that are in the same folder as it. How come it's not affecting other files?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Alright. I gotcha. I started work on V.2, and it will use this.

Problem...

_File_Recurse()
$file_num = $file_num + 1
        $search = $file_list[$file_num]; <<<<----Error is there!
$file_list = _FileListToArray(GUICtrlRead($Input1), "*." & GUICtrlRead($Input2), 1)

: ==> Subscript used with non-Array variable.:

$search = $file_list[1]

$search = $file_list^ ERROR

...god I hate arrays. lol

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Come on...help. I'm bad with arrays! What is the problem...?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Seriously. This can't be that hard.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

$search = String($file_list[$file_num])

?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

C:\Users\Username\Documents\AutoIt Scripts\corrupt2.au3 (262) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
$search = String($file_list[$file_num]) 
$search = String(^ ERROR

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

C:\Users\Derek \Documents\AutoIt Scripts\corrupt2.au3 (262) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
$search = String($file_list[$file_num]) 
$search = String(^ ERROR
Try _ArrayDisplay() and see if your array have the $x element, apparently it doesn't Edited by SmOke_N

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

it shows

[0] [1] [2] and [3]...

If you want I can PM you the code. (to anybody that can help)

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Alright, I've been working on this program that allows me to corrupt files. (It's not done yet) It's intention is for viruses (to help remove them).

Writing an anti-virus program in AutoIT? Are you sure it isn't cheaper in time and resources to use some of the free packages already available?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0