加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
uploadimg.java 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
Lyp 提交于 2021-12-03 10:29 . add uploadimg.java.
private static String numToIP(int addr) {
return (addr & 0x000000FF) + "."
+ ((addr & 0x0000FFFF) >>> 8) + "."
+ ((addr & 0x00FFFFFF) >>> 16) + "."
+ (addr >>> 24);
}
private static void upload(long uin, byte[] ukey, byte[] pic, byte[] md5, String addr, int port, int appid) throws IOException {
PbPack pbPack = new PbPack();
pbPack.setVarint("1.1", 1);
pbPack.setString("1.2", String.valueOf(uin));
pbPack.setString("1.3", "PicUp.DataUp");
pbPack.setVarint("1.4", new Random().nextInt(9999) + 10000);
pbPack.setVarint("1.5", 0);
pbPack.setVarint("1.6", appid);
pbPack.setVarint("1.7", 4096);
pbPack.setVarint("1.8", 1);
pbPack.setVarint("2.2", pic.length);
pbPack.setVarint("2.3", 0);
pbPack.setVarint("2.4", pic.length);
pbPack.setBytes("2.6", ukey);
pbPack.setBytes("2.8", md5);
pbPack.setBytes("2.9", md5);
byte[] array = pbPack.array();
Packet packet = new Packet();
packet.setByte(0x28);
packet.setInt(array.length);
packet.setInt(pic.length);
packet.setBytes(array);
packet.setBytes(pic);
packet.setByte(0x29);
byte[] body = packet.array();
Socket socket = new Socket(addr, port);
OutputStream os = socket.getOutputStream();
os.write(body);
os.flush();
InputStream is = socket.getInputStream();
byte[] buf = new byte[1024];
int len = 0;
while ((len = is.read(buf)) != -1) {
System.out.println(HexUtil.bin2hex(buf, 0, len));
}
socket.close();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化