Implemented FFmpeg Transcoding (#2)

* implemented core ffmpeg functions

[TODO] update README.md and clean code

* Forgot to remove image files afterwards

fucking dumbass

* Upgraded FFmpeg implementation

[^] README.md | for transcoding information
[-] exploits.go | removed skipArg completely as it's not needed at all
[^] exploits.go | changed mode handler because I made a mistake which  makes v the zero duration video mode
[^] .gitignore | added .jpg
[^] transcode-to-webm.go => transcode.go | fixed FFmpeg output and made it print the temporary file location
[^] name.go | made file name longer and changed Unix to UnixNano because the seed as Unix sometimes creates two identical file names when images are transcoded as it is really fast
[^] help.go | changed "doesn't" to "don't"
[^] ffmpeg-check.go | changed error checking function to the one already present in modules/error.go
This commit is contained in:
schmenn 2021-01-15 11:52:04 +01:00 committed by GitHub
parent 24b1b9a48a
commit 5113344272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 146 additions and 23 deletions

6
.gitignore vendored
View file

@ -26,3 +26,9 @@ discord-exploits
discord-exploits-linux-32bit discord-exploits-linux-32bit
discord-exploits-linux-64bit discord-exploits-linux-64bit
*.mp4
*.jpeg
*.jpg

View file

@ -1,13 +1,9 @@
<p align="center">
[![GitHub stars](https://img.shields.io/github/stars/Schmenn/discord-exploits?color=FFFFFF&label=stars&style=flat-square)](https://github.com/Schmenn/discord-exploits/stargazers) [![GitHub stars](https://img.shields.io/github/stars/Schmenn/discord-exploits?color=FFFFFF&label=stars&style=flat-square)](https://github.com/Schmenn/discord-exploits/stargazers)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Schmenn/discord-exploits?color=FFFFFF&style=flat-square) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Schmenn/discord-exploits?color=FFFFFF&style=flat-square)
![GitHub issues](https://img.shields.io/github/issues/Schmenn/discord-exploits?color=FFFFFF&style=flat-square) ![GitHub issues](https://img.shields.io/github/issues/Schmenn/discord-exploits?color=FFFFFF&style=flat-square)
[![GitHub forks](https://img.shields.io/github/forks/Schmenn/discord-exploits?color=FFFFFF&style=flat-square)](https://github.com/Schmenn/discord-exploits/network) [![GitHub forks](https://img.shields.io/github/forks/Schmenn/discord-exploits?color=FFFFFF&style=flat-square)](https://github.com/Schmenn/discord-exploits/network)
![Made with](https://img.shields.io/badge/made%20with-Go-29BEB0?style=flat-square) ![Made with](https://img.shields.io/badge/made%20with-Go-29BEB0?style=flat-square)
</p>
# Discord-Exploits # Discord-Exploits
A program for creating exploited media files for discord written in Go. A program for creating exploited media files for discord written in Go.
@ -33,9 +29,11 @@ the mode `v` stands for virus image
The Program only supports `webm` files for video and `png` files for images The Program only supports `webm` files for video and `png` files for images
##### The file will be saved with a random file name in the directory in which you ran the command ##### The file will be saved with a random file name in the directory in which you ran the command
##### You can use [ffmpeg](https://ffmpeg.org) to convert a video to .webm or to convert an image to png (better than online converters) ##### You can use [FFmpeg](https://ffmpeg.org) to convert a video to .webm or to convert an image to png (better than online converters)
##### The image may get flagged by windows defender and will get removed. to restore the file, go to Settings > Update & Security > Windows Security > Virus & Threat protection and restore the file ##### The "virus" image may get flagged by windows defender and will get removed. to restore the file, go to Settings > Update & Security > Windows Security > Virus & Threat protection and restore the file
### Other file formats
If you want to run this program with other file types like `mp4` and `jpg` directly, make sure you have FFmpeg installed and on your path as the program uses it to transcode the file in those cases.
## Installation ## Installation
### Via releases ### Via releases
@ -61,7 +59,7 @@ linux-32-bit`
`cd discord-exploits` `cd discord-exploits`
3. Compile it 3. Build it
`go build` `go build`
@ -73,6 +71,7 @@ linux-32-bit`
* Feature for creating a video that, when played on discord, will look like it has got a huge negative duration * Feature for creating a video that, when played on discord, will look like it has got a huge negative duration
* Feature for creating a video that, when played on discord, will look like it has got a constant duration of 0 * Feature for creating a video that, when played on discord, will look like it has got a constant duration of 0
* Feature for creating an image then triggers other users' windows defender after being cached * Feature for creating an image then triggers other users' windows defender after being cached
* Transcoding from `mp4` to `webm` and from `jpeg` and `jpg` to `png` ([requires FFmpeg](https://github.com/Schmenn/discord-exploits#other-file-formats))
### Upcoming Features are: ### Upcoming Features are:
not yet decided. not yet decided.

View file

@ -2,23 +2,21 @@ package main
import ( import (
"fmt" "fmt"
"github.com/Schmenn/discord-exploits/exploits"
"github.com/Schmenn/discord-exploits/modules"
"os" "os"
"strings" "strings"
"github.com/Schmenn/discord-exploits/exploits"
"github.com/Schmenn/discord-exploits/modules"
) )
var ( var (
quiet bool = false quiet bool = false
inputFile string = "no input file provided" inputFile string = "no input file provided"
mode string = "no mode specified" mode string = "no mode specified"
//skipArg int = 0
) )
func main() { func main() {
args := os.Args[1:] args := os.Args[1:]
handleArgs(args, &quiet) handleArgs(args, &quiet)
//fmt.Println(quiet)
if !quiet { if !quiet {
modules.Welcome() modules.Welcome()
} }
@ -27,28 +25,23 @@ func main() {
fmt.Println("mode: " + mode) fmt.Println("mode: " + mode)
initCommand(inputFile, mode) initCommand(inputFile, mode)
} }
func handleArgs(args []string, quiet *bool) { func handleArgs(args []string, quiet *bool) {
/*if skipArg > 0 {
skipArg = skipArg - 1
return
}*/
for i, s := range args { for i, s := range args {
switch s { switch s {
// quiet // Quiet
case "-q", "--quiet": case "-q", "--quiet":
*quiet = true *quiet = true
// Input File // Input File
case "-i": case "-i":
//skipArg++
inputFile = args[i+1] inputFile = args[i+1]
// Mode Selection // Mode Selection
case "-m": case "-m":
//skipArg++
mode = args[i+1] mode = args[i+1]
// Help Message // Help Message
@ -64,7 +57,7 @@ func handleArgs(args []string, quiet *bool) {
} }
func initCommand(inputFile string, mode string) { /*func initCommand(inputFile string, mode string) {
inputFile = strings.ToLower(inputFile) inputFile = strings.ToLower(inputFile)
switch strings.ToLower(mode) { switch strings.ToLower(mode) {
case "e": case "e":
@ -73,7 +66,7 @@ func initCommand(inputFile string, mode string) {
exploits.RunExpandingVideoTask(inputFile) exploits.RunExpandingVideoTask(inputFile)
fmt.Println("completed task.") fmt.Println("completed task.")
} else { } else {
fmt.Println("File is not a webm, check -h") fmt.Println("File is not a webm or mp4, check -h")
} }
case "n": case "n":
if strings.HasSuffix(inputFile, ".webm") { if strings.HasSuffix(inputFile, ".webm") {
@ -101,3 +94,92 @@ func initCommand(inputFile string, mode string) {
} }
} }
} }
*/
func initCommand(inputFile string, mode string) {
inputFile = strings.ToLower(inputFile)
if strings.HasSuffix(inputFile, ".webm") {
switch mode {
case "e":
fmt.Println("editing video.")
exploits.RunExpandingVideoTask(inputFile)
fmt.Println("completed task.")
case "n":
fmt.Println("editing video.")
exploits.RunNegativeVideoTask(inputFile)
fmt.Println("completed task.")
case "0", "z":
fmt.Println("editing video.")
exploits.RunZeroVideoTask(inputFile)
fmt.Println("completed task.")
default:
fmt.Println("the mode doesn't match the file")
}
} else if strings.HasSuffix(inputFile, ".mp4") {
switch mode {
case "e":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunExpandingVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
case "n":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunNegativeVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
case "0", "z":
fmt.Println("transcoding video from mp4 to webm")
out := modules.Transcode(inputFile, "webm")
fmt.Println("finished transcoding video from mp4 to webm")
fmt.Println("editing video.")
exploits.RunZeroVideoTask(out)
fmt.Println("completed task.")
os.Remove(out)
default:
fmt.Println("the mode doesn't match the file")
}
} else if strings.HasSuffix(inputFile, ".png") {
fmt.Println("editing photo.")
exploits.RunVirusImageTask(inputFile)
fmt.Println("completed task.")
} else if strings.HasSuffix(inputFile, ".jpg") {
fmt.Println("transcoding image from jpg to png")
out := modules.Transcode(inputFile, "png")
fmt.Println("finished transcoding image from jpg to png")
fmt.Println("editing photo.")
exploits.RunVirusImageTask(out)
fmt.Println("completed task.")
os.Remove(out)
} else if strings.HasSuffix(inputFile, ".jpeg") {
if strings.ToLower(mode) != "v" || strings.ToLower(mode) == "no mode specified"{
fmt.Println("the mode is not compatible with the image, proceeding to run the virus image task anyway")
}
fmt.Println("transcoding image from jpeg to png")
out := modules.Transcode(inputFile, "png")
fmt.Println("finished transcoding image from jpeg to png")
fmt.Println("editing photo.")
exploits.RunVirusImageTask(out)
fmt.Println("completed task.")
os.Remove(out)
} else {
if inputFile == "no input file provided" {
return
}
}
}

14
modules/ffmpeg-check.go Normal file
View file

@ -0,0 +1,14 @@
package modules
import (
"os/exec"
)
// CheckForFFmpeg looks for ffmpeg in the path
func CheckForFFmpeg() string {
path, err := exec.LookPath("ffmpeg")
Check(err)
return path
}

View file

@ -9,7 +9,7 @@ func Help(progName string) {
fmt.Println("Discord-Exploits Help") fmt.Println("Discord-Exploits Help")
fmt.Println(" Usage: " + progName + " -i <input file> -m <mode> [-q]") fmt.Println(" Usage: " + progName + " -i <input file> -m <mode> [-q]")
fmt.Println("") fmt.Println("")
fmt.Println("--quiet -q doesn't show welcome screen") fmt.Println("--quiet -q don't show welcome screen")
fmt.Println("-i <file> provide input file") fmt.Println("-i <file> provide input file")
fmt.Println("-m <mode> specify mode") fmt.Println("-m <mode> specify mode")
fmt.Println("") fmt.Println("")

View file

@ -8,8 +8,8 @@ import (
// CreateName generates a random file name // CreateName generates a random file name
func CreateName(extension string) string { func CreateName(extension string) string {
charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, 6) b := make([]byte, 8)
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().UnixNano())
for i := range b { for i := range b {
b[i] = charset[rand.Intn(len(charset))] b[i] = charset[rand.Intn(len(charset))]
} }

22
modules/transcode.go Normal file
View file

@ -0,0 +1,22 @@
package modules
import (
"fmt"
"os/exec"
)
//Transcode transcodes videos and images
func Transcode(input string, to string) string {
path := CheckForFFmpeg()
output := CreateName(to)
out, err := exec.Command(path, "-i", input, output).CombinedOutput()
Check(err)
fmt.Println("temporarily saving transcoded file to " + output)
fmt.Println(string(out))
return output
}