Hack Forums
[.NET] How To Create A Campaign Within Your Program - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] How To Create A Campaign Within Your Program (/showthread.php?tid=4611402)



How To Create A Campaign Within Your Program - 270z - Dec 30, 2014

Okay Guys, I have asked many questions here and would like to take a moment to contribute back to the forum now!

Some pro's here might think this was coded poorly, but it works :D

What the form would look like:
[Image: rWcXCb8.png]

1: When the program is launched you must create folders and txt's for your program.
Code
If (Not System.IO.Directory.Exists("C:\pasteboy")) Then
            System.IO.Directory.CreateDirectory("C:\pasteboy")
        End If
        HurrycanProgressBar1.Increment(34)
        If (Not System.IO.Directory.Exists("C:\pasteboy\campaigns")) Then
            System.IO.Directory.CreateDirectory("C:\pasteboy\campaigns")
        End If
        HurrycanProgressBar1.Increment(34)
        If Not System.IO.File.Exists("C:\pasteboy\settings.txt") Then
            System.IO.File.Create("C:\pasteboy\settings.txt").Dispose()
        End If
        HurrycanProgressBar1.Increment(32)

2: Add the settings or inputs for the campaign and the listview
[Image: rWcXCb8.png]

4: Make it add and save

Code
Private Sub HurrycanButton2_Click(sender As Object, e As EventArgs) Handles HurrycanButton2.Click
        Dim Campaign As New ListViewItem(txtbxName.Text) 'Name
        Campaign.SubItems.Add(txtbxKW.Text) 'KW
        Dim type As String
        If rndmChk.Checked = True Then
            type = "Random"
        Else
            type = pastetypeCombo.Text
        End If
        Campaign.SubItems.Add(type) 'Type
        Dim expire As String
        If expirerndmchk.Checked = True Then
            expire = "Random"
        Else
            expire = expireCombo.Text
        End If
        Campaign.SubItems.Add(expire)
        ListView1.Items.Add(Campaign)

        If (Not System.IO.Directory.Exists("C:\pasteboy\campaigns\" & txtbxName.Text)) Then
            System.IO.Directory.CreateDirectory("C:\pasteboy\campaigns\" & txtbxName.Text)
        Else
            MsgBox("Error: Campaign Name Allready Exists!")
        End If

        If Not System.IO.File.Exists("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt") Then
            System.IO.File.Create("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt").Dispose()
            Dim file As System.IO.StreamWriter
            file = My.Computer.FileSystem.OpenTextFileWriter("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt", True)
            file.Write(txtbxName.Text & ":" & txtbxKW.Text & ":" & type & ":" & expire)
            file.Close()
        Else
            MsgBox("Error: Campaign Name Already Exists!")
        End If

        ListView1.Items.Clear()
        Try
            Dim Dirs() As String = Directory.GetDirectories("C:\pasteboy\campaigns")
            For Each Dir As String In Dirs
                GetCampaign(Dir)
            Next
        Catch ex As Exception
        End Try

    End Sub

what this will do is create a campaign if one of that name does not already exist. If it doesn't then it will create a folder containing the settings of the campaign. This is so later in the program the folder can hold other stuff for that campaign like another txt with proxies or whatnot ;)

5: Make it load the list of campaigns
NOTE- I added this many places throughout the code of my program but I will show you one place to make it simple to understand

This is that little refresh picture on the bottom right of the listview ;)

Code
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        ListView1.Items.Clear()
        Try
            Dim Dirs() As String = Directory.GetDirectories("C:\pasteboy\campaigns")
            For Each Dir As String In Dirs
                GetCampaign(Dir)
            Next
        Catch ex As Exception
        End Try

    End Sub


6: Now to let the user Edit the campaign.

You can do double click or selected index changed for this part, I chose index changed because it is faster for me when testing xD

Code
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged

        txtbxName.Enabled = False

        txtbxName.Text = ListView1.FocusedItem.SubItems(0).Text
        txtbxKW.Text = ListView1.FocusedItem.SubItems(1).Text        

        If ListView1.FocusedItem.SubItems(2).Text = "Random" Then
            rndmChk.Checked = True
            expireCombo.Text = ""
        Else
            rndmChk.Checked = False
            pastetypeCombo.Text = ListView1.FocusedItem.SubItems(2).Text
        End If

        If ListView1.FocusedItem.SubItems(3).Text = "Random" Then
            expirerndmchk.Checked = True
            expireCombo.Text = ""
        Else
            expirerndmchk.Checked = False
            expireCombo.Text = ListView1.FocusedItem.SubItems(3).Text
        End If

    End Sub

Then The edit button itself:
Code
ListView1.Clear()

        Dim Campaign As New ListViewItem(txtbxName.Text) 'Name
        Campaign.SubItems.Add(txtbxKW.Text) 'KW
        Dim type As String
        If rndmChk.Checked = True Then
            type = "Random"
        Else
            type = pastetypeCombo.Text
        End If
        Campaign.SubItems.Add(type) 'Type
        Dim expire As String
        If expirerndmchk.Checked = True Then
            expire = "Random"
        Else
            expire = expireCombo.Text
        End If
        Campaign.SubItems.Add(expire)

        System.IO.File.Delete("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt")
        System.IO.File.Create("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt").Dispose()
        Dim file As System.IO.StreamWriter
        file = My.Computer.FileSystem.OpenTextFileWriter("C:\pasteboy\campaigns\" & txtbxName.Text & "\settings.txt", True)
        file.Write(txtbxName.Text & ":" & txtbxKW.Text & ":" & type & ":" & expire)
        file.Close()

        ListView1.Items.Clear()
        Try
            Dim Dirs() As String = Directory.GetDirectories("C:\pasteboy\campaigns")
            For Each Dir As String In Dirs
                GetCampaign(Dir)
            Next
        Catch ex As Exception
        End Try




Now with this made the user can select their campaigns through a dropdown as such:
[Image: w58rUGT.png]

This is where my code gets really sketchy...
Code
HurrycanComboBox2.Items.Clear()

        Try
            Dim Dirs() As String = Directory.GetDirectories("C:\pasteboy\campaigns")
            For Each Dir As String In Dirs
                HurrycanComboBox2.Items.Add(Dir.Replace("C:\pasteboy\campaigns\", ""))
            Next
        Catch ex As Exception
        End Try

I say that it is sketchy because if there are alot of campaigns it takes a little while to load the campaigns so you might need to work on that part. But for the purpose of the code I think I did pretty well on this 👍


I hope this helps some of you and if you have any questions feel free to ask!
Here are a couple pictures of it:
[Image: pwXrjM8.png]
[Image: gaFJGg6.png]
[Image: yAhbsBG.png]
[Image: gCKXwjw.png]