Remove file renaming

Update tests
Add new lines test
pull/94/head
Pagran 5 years ago
parent 05b4f88c71
commit 6f2da836a0

@ -513,7 +513,6 @@ func transformCompile(args []string) ([]string, error) {
protectFileName = true
file = transformLineInfo(i, file)
file = transformGo(file, info, blacklist)
name = fmt.Sprintf("z%d.go", i)
// Uncomment for some quick debugging. Do not delete.
// fmt.Fprintf(os.Stderr, "\n-- %s/%s --\n", pkgPath, origName)

@ -27,7 +27,7 @@ stdout 'unknown'
! stdout $gofullversion
# The binary can't contain the version string either.
! binsubstr main$exe ${WORK@R} 'globalVar' 'globalFunc' $gofullversion 'z0.go'
! binsubstr main$exe ${WORK@R} 'main.go' 'globalVar' 'globalFunc' $gofullversion
[short] stop # checking that the build is reproducible is slow
@ -50,7 +50,7 @@ cmp stderr main.stderr
# The default build includes full non-trimmed paths, as well as our names.
# Only check $WORK on non-windows, because it's difficult to do it there.
binsubstr main$exe 'globalVar' 'globalFunc' $gofullversion
binsubstr main$exe 'main.go' 'globalVar' 'globalFunc' $gofullversion
[!windows] binsubstr main$exe ${WORK@R}
-- main.go --

@ -1,8 +1,7 @@
garble -debugdir ./test1 build
exists 'test1/test/imported/z0.go' 'test1/main/z0.go'
! grep ImportedFunc $WORK/test1/test/imported/z0.go
! grep ImportedFunc $WORK/test1/main/z0.go
exists 'test1/test/imported/imported.go' 'test1/main/main.go'
! grep ImportedFunc $WORK/test1/test/imported/imported.go
! grep ImportedFunc $WORK/test1/main/main.go
-- go.mod --
module test

@ -0,0 +1,62 @@
garble -debugdir=.obf-src build
env TINY_PATTERN='^\/\/line :1$'
env DEFAULT_PATTERN='^\/\/line \w\.go:[1-9][0-9]*$'
env DEFAULT_STACK_PATTERN='^\t\w\.go:[1-9][0-9]*(\s\+0x[0-9a-f]+)?'
env TINY_STACK_PATTERN='^\t\?\?:[0-9][0-9]*(\s\+0x[0-9a-f]+)?$'
# Default mode
# Check for file name leak protection
grep $TINY_PATTERN $WORK/.obf-src/main/main.go
grep $TINY_PATTERN $WORK/.obf-src/main/main1.go
# Check for default line obfuscation
grep $DEFAULT_PATTERN $WORK/.obf-src/main/main.go
grep $DEFAULT_PATTERN $WORK/.obf-src/main/main1.go
exec ./main$exe
cp stderr default.stderr
! grep 'main1?\.go' default.stderr
! grep $TINY_STACK_PATTERN default.stderr
grep $DEFAULT_STACK_PATTERN default.stderr
# Tiny mode
garble -tiny -debugdir=.obf-src build
grep $TINY_PATTERN $WORK/.obf-src/main/main.go
grep $TINY_PATTERN $WORK/.obf-src/main/main1.go
! grep $DEFAULT_PATTERN $WORK/.obf-src/main/main.go
! grep $DEFAULT_PATTERN $WORK/.obf-src/main/main1.go
exec ./main$exe
cp stderr tiny.stderr
! grep 'main1?\.go' tiny.stderr
! grep $DEFAULT_STACK_PATTERN tiny.stderr
grep $TINY_STACK_PATTERN tiny.stderr
-- go.mod --
module main
-- main.go --
package main
import "runtime/debug"
func dump1() {
debug.PrintStack()
}
func main() {
dump1()
dump2()
}
-- main1.go --
package main
import "runtime/debug"
func dump2() {
debug.PrintStack()
}

@ -37,19 +37,19 @@ cmp stderr normal.stderr
# Check obfuscators
# Xor obfuscator. Detect a[i] = a[i] (^|-|+) b[i]
grep '^\s+\w+\[\w+\] = \w+\[\w+\] [\^\-+] \w+$' .obf-src/main/z0.go
grep '^\s+\w+\[\w+\] = \w+\[\w+\] [\^\-+] \w+$' .obf-src/main/extraLiterals.go
# Swap obfuscator. Detect [...]byte|uint16|uint32|uint64{...}
grep '^\s+\w+ := \[\.{3}\](byte|uint16|uint32|uint64)\{[0-9\s,]+\}$' .obf-src/main/z0.go
grep '^\s+\w+ := \[\.{3}\](byte|uint16|uint32|uint64)\{[0-9\s,]+\}$' .obf-src/main/extraLiterals.go
# Split obfuscator. Detect decryptKey ^= i * counter
grep '^\s+\w+ \^= \w+ \* \w+$' .obf-src/main/z0.go
grep '^\s+\w+ \^= \w+ \* \w+$' .obf-src/main/extraLiterals.go
# XorShuffle obfuscator. Detect data = append(data, x (^|-|+) y...)
grep '^\s+\w+ = append\(\w+,(\s+\w+\[\d+\][\^\-+]\w+\[\d+\],?)+\)$' .obf-src/main/z0.go
grep '^\s+\w+ = append\(\w+,(\s+\w+\[\d+\][\^\-+]\w+\[\d+\],?)+\)$' .obf-src/main/extraLiterals.go
# XorSeed obfuscator. Detect type decFunc func(byte) decFunc
grep '^\s+type \w+ func\(byte\) \w+$' .obf-src/main/z0.go
grep '^\s+type \w+ func\(byte\) \w+$' .obf-src/main/extraLiterals.go
-- go.mod --

@ -11,7 +11,7 @@ cmp stderr main.stderr
! binsubstr main$exe 'localName' 'globalConst' 'globalVar' 'globalType' 'valuable information'
binsubstr debug/main/z1.go 'localName' 'globalConst'
binsubstr debug/main/scopes.go 'localName' 'globalConst'
-- go.mod --
module test/main

Loading…
Cancel
Save