Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: expected ')' at end of argument list #1

Open
NotoriousRebel opened this issue Aug 27, 2020 · 8 comments
Open

Error: expected ')' at end of argument list #1

NotoriousRebel opened this issue Aug 27, 2020 · 8 comments

Comments

@NotoriousRebel
Copy link

NotoriousRebel commented Aug 27, 2020

Hello, I finally got a chance to use this awesome project for something I am working on; however, I have run into some issues and am not sure how easy they are to fix.

root@gotham:/home/x/llvm-9.0.1.src# ./build/bin/opt -load build/lib/LLVMObf.so -vm -flattening -connect test.ll -o test.obc.bc
./build/bin/opt: test.ll:114:22: error: expected ')' at end of argument list
define i32 @main(i32 %0, i8** nocapture readnone %1) local_unnamed_addr {
                     ^

The IR was generated using nlvm.

test.nim:

echo "hello world"

and to get the IR:

nlvm c -c test.nim

It does turn out to 14,000 lines without any optimization so I optimized it

opt -Os test.ll | llvm-dis > test.ll

Without the optimizations I changed %0 and %1 to %a and %b and then attempted to generate obfuscated bytecode; however, after 30 minutes it was still running so I canceled it.

@emc2314
Copy link
Owner

emc2314 commented Aug 27, 2020

The code I wrote is not robust at all especially when it comes to unwind/exception etc...
I would suggest you to try just one kind of obfuscation pass per run and reduce your input file to a minimal example which can reproduce this bug so that I can dig more into it.

@NotoriousRebel
Copy link
Author

NotoriousRebel commented Aug 27, 2020

Thanks for the quick reply, I am not sure how much further I can reduce the nim file as it's as rudimentary as you can get. I can send you the IR files if you would like or provide a bash script to automate the installation of nlvm on Ubuntu 18.04 or 20.04. When optimized the IR file is reduced to 5083 lines. I reduced it to just -vm and still run into the same error I am not sure how easy it is to replace Unnamed temporaries such as %0, %1, etc.... that may solve the issues I am running into.

@emc2314
Copy link
Owner

emc2314 commented Aug 28, 2020

You can attach the (optimized) IR file (.bc file is ok) here so I can try to find out what's going on. Maybe I should add an option to let user determine which function to obfuscate.

@NotoriousRebel
Copy link
Author

NotoriousRebel commented Aug 28, 2020

Sounds good here is the optimized IR file: obtained as mentioned above also for the hello world example if I just get rid of %0 and %1 it works. However, I will need to conduct further testing as if arguments are being passed into the program that is not ideal and if more unnamed temporaries renaming them or removing them may cause the program to break.

define i32 @main(i32, i8** nocapture readnone)

At least with VM, flattening, and connect I think it's Obfcall but one command is not working or maybe it is but taking a long time I cancelled after 10 minutes.

@NotoriousRebel
Copy link
Author

@emc2314 any luck?

@emc2314
Copy link
Owner

emc2314 commented Sep 15, 2020

Sorry for taking so long time, but I was quite busy on other projects. I will update this thread as soon as there is any clue. I can't say "plz stay tuned" but hopefully I will have some spare time at the end of this month. Anyway thank you for your issue report, I really appreciate that this simple project might be helpful for someone.

@NotoriousRebel
Copy link
Author

@emc2314 Just want to check in as I can imagine just how busy you are. No rush just wanted to check-in.

@viroulep
Copy link

It looks like the nlvm version you used must be based on LLVM 10 or later, whereas this project is based on LLVM 9; there was a change in the IR in version 10 where they now explicitly print unnamed parameters.

I'm not familiar with nlvm but if possible I'd suggest to use an earlier version of nlvm based on LLVM <=9, if it exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants