我正在尝试读取二进制文件以从不同位置获取字符串;读取 {IP,login,pwd} 我的想法是找到第一个 ip 并在之后读取数据,因为之间的长度是一样的:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000060 5F 00 00 00 00 11 E0 BB 5F 00 00 00 00 01 34 31 _.....à»_.....40
00000070 2E 31 39 31 2E 39 37 2E 36 32 00 00 00 00 00 00 .091.17.02......
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000090 00 00 73 75 70 70 6F 72 74 00 00 00 00 00 00 00 ..support.......
000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
我的围棋代码
import (
"io"
"log"
"os"
)
func main() {
file, err := os.Open("data")
if err != nil {
log.Fatal(err)
}
defer file.Close()
o2, err := file.Seek(110, io.SeekCurrent) <---- find first occurrence
byteSlice := make([]byte, 32)
bytesRead, err := file.Read(byteSlice)
if err != nil {
log.Fatal(err)
}
log.Printf("IP: %s\n", byteSlice)
}
如何在找到 ip 后找到所有出现的 { ip, login, pwd },用我的代码我只能找到第一个 (ip) 32 位。
去
皈依舞
繁花如伊
相关分类