You are not logged in.

#1 2014-02-01 16:56:10

axper
Member
Registered: 2013-01-25
Posts: 115

[SOLVED] [REQUEST] objobf

This is an old but very interesting pice of code which I can't get working.
It uses a shell script to generate a header file #defines, but while doing so it uses old/removed options of commands `sort` and `uniq`. I fixed the issue with `uniq` using info from here (http://unix.stackexchange.com/questions … -uniq-t-do) but I don't know enough about `sort` and other commands to get it working. Any help or advice appreciated.

# Maintainer: 

pkgname=objobf
pkgver=0.5.0
pkgrel=1
pkgdesc="x86/Linux ELF relocateable object obfuscator"
arch=('i686' 'x86_64')
url="https://web.archive.org/web/20040406115208/http://www.team-teso.net/projects/objobf/"
license=('LGPL')
depends=()
source=(
	"https://web.archive.org/web/20040217131820/http://www.team-teso.net/projects/objobf/objobf-0.5.0.tar.bz2"
	"uniq.patch")
md5sums=(
	'ba6b6f098f2c1e48c6946c6b13f568bb'
	'6ff961fce3400141eebfa9f824db8a39')

build() {
	cd $srcdir/$pkgname-$pkgver
  patch -p1 -i $srcdir/uniq.patch 

	cd $srcdir/$pkgname-$pkgver/src
	make
}

package() {
	cd $srcdir/$pkgname-$pkgver/src

	# ??????????

	# Untested below
	# Manpage
	cd $srcdir/$pkgname-$pkgver/doc
	gzip objobf.1
	cp objobf.1.gz $pkgdir/usr/share/man/man1/

	# Docs
	mkdir -p $pkgdir/usr/share/doc/objobf
	cp -r $srcdir/$pkgname-$pkgver/doc $pkgdir/usr/share/
}

# vim:set ts=2 sw=2 et:

uniq.patch

diff -aur objobf-0.5.0/src/ia32/build-opcode-list.sh objobf-0.5.0.new/src/ia32/build-opcode-list.sh
--- objobf-0.5.0/src/ia32/build-opcode-list.sh  2003-08-09 23:23:50.000000000 +0500
+++ objobf-0.5.0.new/src/ia32/build-opcode-list.sh  2014-02-01 20:35:32.781678037 +0400
@@ -14,7 +14,8 @@
 egrep -n "{ IA32_OP" ia32-decode.c | \
    awk '{ print $1 $3 $4 }' | \
    sort -t '(' +1 | \
-   uniq -t ':' -f 1 | \
+   sed 's/:/ /' | \
+   uniq -f 1 | \
    sed 's/\(.*\)\:IA32_OP(\(.*\)),/#define IA32_OP_\2 \1/g' >> ia32_opcodes.h
 
 cat >> ia32_opcodes.h << __EOF__

Last edited by axper (2014-02-01 18:12:46)

Offline

#2 2014-02-01 17:07:08

Raynman
Member
Registered: 2011-10-22
Posts: 1,094

Re: [SOLVED] [REQUEST] objobf

This man page describes both styles for specifying the sort field. It seems the equivalent to +1 would be -k2.

You should patch in the prepare() function in the PKGBUILD and makepkg should handle gzipping the man page.

Last edited by Raynman (2014-02-01 17:10:47)

Offline

#3 2014-02-01 17:25:44

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [SOLVED] [REQUEST] objobf

Hmm, I changed it to

egrep -n "{ IA32_OP" ia32-decode.c | \
	awk '{ print $1 $3 $4 }' | \
	sort -t '(' -k2 | \
	sed 's/:/ /' | \
	uniq -f 1 | \
	sed 's/\(.*\)\:IA32_OP(\(.*\)),/#define IA32_OP_\2 \1/g' >> ia32_opcodes.h

But it still generated wrong ia32_opcodes.h file.

I maually edited ia32_opcodes.h like this

#define IA32_OP_aaa 71
#define IA32_OP_aad 75
#define IA32_OP_aam 81
#define IA32_OP_aas 87

since that's what author seems to want, but it fails with this error:

ia32-function.c: In function ‘ia32_linux_interrupt_decode’:
ia32-function.c:2564:8: error: ‘__NR_sigreturn’ undeclared (first use in this function)
  case (__NR_sigreturn):
        ^
ia32-function.c:2564:8: note: each undeclared identifier is reported only once for each function it appears in
ia32-function.c: In function ‘ia32_func_list_dump’:
ia32-function.c:3063:4: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    (unsigned int) flist[n]->mem);
    ^
<builtin>: recipe for target 'ia32-function.o' failed
make: *** [ia32-function.o] Error 1

Needs someone with more experience.

Offline

#4 2014-02-01 18:07:35

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,071

Re: [SOLVED] [REQUEST] objobf

Try changing the header from <asm/unistd.h> to <asm/unistd_32.h>

Offline

#5 2014-02-01 18:12:52

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [SOLVED] [REQUEST] objobf

It worked! Thank you so much! Now need to learn sed and stuff to format the header...

Offline

#6 2014-02-01 19:48:05

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [SOLVED] [REQUEST] objobf

Offline

#7 2014-02-01 20:13:07

Raynman
Member
Registered: 2011-10-22
Posts: 1,094

Re: [SOLVED] [REQUEST] objobf

Your PKGBUILD needs some more work. See my previous reply and maybe just try running makepkg because it's obviously broken. You should also quote variables and consider install instead of cp/mkdir (except for the recursive cp, see https://mailman.archlinux.org/pipermail … 16778.html ).

Offline

#8 2014-02-02 05:46:17

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [SOLVED] [REQUEST] objobf

Fixed, thanks!

Offline

Board footer

Powered by FluxBB