News for hackers. Stuff that matters.
Re:Reversing Go Binaries Like a Pro by kevinburke on Thursday December 15, 2016 @08:28PM (#13190350)
I'm getting a Chromium security error because this website is presenting a certificate from *.github.com.
Re:Reversing Go Binaries Like a Pro by FiloSottile on Thursday December 15, 2016 @08:35PM (#13190378)
It's my fault. I use HTTPS Everywhere in full HTTP blocking mode, so when a link isn't HTTPS I just try manually, and accept the error for common Akamai and Github Pages certs, which is still much better than HTTP (for random sites).

But then I ended up submitting that broken link. The interesting thing is that it reached the top (#4 right now) of HN anyway.

Re:Reversing Go Binaries Like a Pro by tedunangst on Thursday December 15, 2016 @08:57PM (#13190456)
Go? Reversing? Say no more, have an upvote!
Re:Reversing Go Binaries Like a Pro by cconover on Thursday December 15, 2016 @08:29PM (#13190356)
Me too.
Re:Reversing Go Binaries Like a Pro by differentials on Thursday December 15, 2016 @08:35PM (#13190379)
Author here... Link was submitted using https which I had not set up yet. Just switched over to a CF nameserver so it should be working shortly...
Re:Reversing Go Binaries Like a Pro by cbdfghh on Thursday December 15, 2016 @10:49PM (#13190910)
Just curious, is a Go string a C string inside (rune array + nil) or a proper class array?

In other words, in

a:="b"+"c"

IOW, does it implement the Slemiel's painting algorithm or not?

Re:Reversing Go Binaries Like a Pro by barsonme on Thursday December 15, 2016 @10:59PM (#13190960)
I'm not sure I 100% understand your question, but in Go a string is a two-word struct.

    type string struct {
        data unsafe.Pointer
        len int
    }
The C version would be

    typedef struct string {
        const *char data;
        int len;
    } string;
Edit: oh, ok. I Googled the "painting algorithm" reference. I swear I had read that before :-)
Re:Reversing Go Binaries Like a Pro by Someone on Friday December 16, 2016 @07:43AM (#13192845)
If you consider googling it too: http://wiki.c2.com/?ShlemielThePainter
Re:Reversing Go Binaries Like a Pro by razakel on Friday December 16, 2016 @04:23AM (#13192076)
>Just curious, is a Go string a C string inside (rune array + nil) or a proper class array?

I can't imagine how you would even implement a string as anything other than a rune array.

Even a Pascal string is just the string length followed by characters.

Re:Reversing Go Binaries Like a Pro by chrisseaton on Friday December 16, 2016 @06:54AM (#13192635)
> I can't imagine how you would even implement a string as anything other than a rune array.

You can also implement strings using a tree data structure. We do this in an implementation of Ruby that I work on because it can make concatenation faster.

Re:Reversing Go Binaries Like a Pro by Someone on Friday December 16, 2016 @07:24AM (#13192761)
A text editor edits a (potentially very long) string, but apart from, possibly, the likes of Notepad, none of them store that string as a single byte array.

So, look at text editor data structures for other representations. Examples:

- https://en.wikipedia.org/wiki/Gap_buffer

- https://en.wikipedia.org/wiki/Rope_(computer_science)

- https://en.wikipedia.org/wiki/Piece_table

Re:Reversing Go Binaries Like a Pro by unwind on Friday December 16, 2016 @07:50AM (#13192872)
In Haskell strings are lists of characters (https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-S...). I hear not everyone is thrilled with the performance implications. :)

Also not a Haskell programmer, and really not meaning to criticize. Haskell seems awesome and I should learn it some day.

Re:Reversing Go Binaries Like a Pro by jerf on Friday December 16, 2016 @08:28AM (#13193060)
Just so people know, there are arrays used for text manipulation in Haskell in the Data.Text library, and bytestrings in the ByteString library. The language as specified does indeed have strings in a linked list of numbers, but if you even remotely care about performance you don't use those, and most libraries don't either nowadays.
Re:Reversing Go Binaries Like a Pro by unwind on Monday December 19, 2016 @04:06AM (#13210345)
Thanks! I guess I was kind of hoping for someone with actual knowledge to fill in the details.
Re:Reversing Go Binaries Like a Pro by thwd on Friday December 16, 2016 @06:40AM (#13192572)
as C does: with a \00 end marker.
Re:Reversing Go Binaries Like a Pro by javathrowaway on Friday December 16, 2016 @09:40AM (#13193488)
Yeah, and how do you store NUL chars in those C strings then?

The answer is you can't. Because prefix-length strings (Pascal) are far better than null-terminated (C) strings.

Re:Reversing Go Binaries Like a Pro by devoply on Thursday December 15, 2016 @11:36PM (#13191105)
Glad to see the code still looks like crap, beautiful assembly, so using any of that is not going to make sense. Which is good news for distributing a Go binary.
Re:Reversing Go Binaries Like a Pro by mappu on Thursday December 15, 2016 @10:39PM (#13190868)
> You can quiet easily differentiate between custom code written for the binary, for example in the Linux malware “Rex” everything because with that name space!

Really? It looks like only `runtime_` gets the prefix, so third-party libraries and code in go/src (e.g. `fmt`) would get mixed in here too, right?

Re:Reversing Go Binaries Like a Pro by differentials on Friday December 16, 2016 @12:33PM (#13194996)
Everything get prefixed by the package namespace, so things pulled from github.com/group_name/package ends up looking like `github_com_group_name_package_class_funcname. This why why "rebuilding" the function names was a good way to quickly filter out the "known" code from the malicious functionality.
Re:Reversing Go Binaries Like a Pro by ninov on Friday December 16, 2016 @06:32PM (#13197868)
Is this really how the names are represented internally? if so, how can it tell apart e.g. "github.com/group_name/package" and "github.com/group/name_package"?
Re:Reversing Go Binaries Like a Pro by differentials on Friday December 16, 2016 @10:25PM (#13199007)
Good question, I assume there is some way the compiler/runtime would dedupe these for the coder at compile time. However I don't honestly know enough about the Go internals... Honestly, I wrote more Go code during this blog post than I ever had, even though I had been reversing it for a while...
Re:Reversing Go Binaries Like a Pro by mappu on Friday December 16, 2016 @07:52PM (#13198310)
So you can achieve smaller (/obfuscated) binaries by automatically renaming everything in $GOPATH to short unique strings? That would be a neat project.
Re:Reversing Go Binaries Like a Pro by differentials on Friday December 16, 2016 @10:23PM (#13199004)
Yes, you could in theory rename everything prior to compilation for obfuscation/space saving - similar to how (some) Java protections worked.
Re:Reversing Go Binaries Like a Pro by nadermx on Thursday December 15, 2016 @09:10PM (#13190517)
Re:Reversing Go Binaries Like a Pro by differentials on Thursday December 15, 2016 @10:33PM (#13190847)
The https link should be working now, switched over to cloudflare. Thanks for the link though!
Re:Reversing Go Binaries Like a Pro by alblue on Friday December 16, 2016 @04:47AM (#13192175)
There's a typo in the write up - lenght
Re:Reversing Go Binaries Like a Pro by fbreduc on Thursday December 15, 2016 @08:25PM (#13190337)
if err != nil ?