Go语言程序调试

1. Go语言二进制程序分析
   在分析一些使用GOlang语言进行编译的恶意程序时,由于程序在被打包成二进制程序时会打包诸多引用的库,并且作者对二进制程序进行了去符号化,导致在动态或是静态分析时函数过多而不便于跟踪。
   而如果GO编译成的二进制程序并未进行去符号化,那么在IDA中进行分析时,几乎可以相当于看源码了。所以只要将去符号的程序进行符号恢复,那么之后调试时就十分方便了。
   可以使用Github上的ida py脚本IDAGolangHelper,关于Go程序恢复符号的资料:[https://2016.zeronights.\ru/wp-content/uploads/2016/12/GO_Zaytsev.pdf](https://2016.zeronights. ru/wp-content/uploads/2016/12/GO_Zaytsev.pdf),主要就是为了确认Go语言程序特有的.gopclntab段位置,中文可以参考以下https://www.freebuf.com/articles/others-articles/176803.html

   另外还可以使用Redress对程序包结构进行分析。

2. 加密函数

EnryptOAEP/DecryptOAEP

// EncryptOAEP encrypts the given message with RSA-OAEP.
//
// OAEP is parameterised by a hash function that is used as a random oracle.
// Encryption and decryption of a given message must use the same hash function
// and sha256.New() is a reasonable choice.
//
// The random parameter is used as a source of entropy to ensure that
// encrypting the same message twice doesn't result in the same ciphertext.
//
// The label parameter may contain arbitrary data that will not be encrypted,
// but which gives important context to the message. For example, if a given
// public key is used to decrypt two types of messages then distinct label
// values could be used to ensure that a ciphertext for one purpose cannot be
// used for another by an attacker. If not required it can be empty.
//
// The message must be no longer than the length of the public modulus minus
// twice the hash length, minus a further 2.

EncryptOAEP(hash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, label []byte)
  查看相关源码后,可以知道散列函数hash被用于计算label的hash值;random参数产生hash.size()个强随机数作为seed;计算seed的hash值与包括明文和label的hash值在内的数据进行异或,从而防止旁路攻击。最终使用公钥加密包括seed、hash(label)、明文在内的数据,作为密文。

  加密的消息必须不大于(公钥长度 - 2*hash.size() - 2)。

posted @ 2020-04-19 15:36  Bl0od  阅读(726)  评论(0编辑  收藏  举报