A, goals,

Explode liver + stay up late, finally run so with unidBG, can’t put in hard drive mold. We need to use it in a generation environment.

The most convenient way is to rent a cloud server and deploy Unidbg on it to provide cloud signature services to our worker applications.

  • unidbg
  • Unidbg-server

Second, the steps

Unidbg-server

You have to be an old Java artist to play Unidbg. The Cxapython masters offer a solution for running Unidbg through Springboot:

Github.com/cxapython/u…

Git Clone down, and then import into idea

Then, compile and run……

ffMac:unidbgweb fenfei$ python3 send.py
{'X-Khronos': '1627183488', 'X-Gorgon': '0401007008006c494547b54e36413a81b1a8118d238f2dffd9b3'}
Copy the code

Run through the example provided by the author

I’ll go. I’ll go. I’ll go. Is that what the big open source guys are doing now?Right out of the box.

Where is the Unidbg

We only downloaded the code of unidbg-server, but did not download the code of Unidbg? Why can you just run?

The mystery is in pom.xml, loaded with the unidbg module online, so you can run directly.

add

We are already familiar with Unidbg from the previous study, so we may have maintained a custom modification. So the question is, can we not load the Unidbg code online, but load our native version?

  • Our customised version of the first unidbg compiled into jars, reference 91 fans.com.cn/post/unidbg…

  • Create a new libs directory in the root directory of the unidbg-server project (the same directory as pom.xml)

Copy a bunch of jar packages from the custom version of UnidBG

  • Modified pom. XML
// Delete these two paragraphs, Unidbg <dependency> <groupId>com.github. Zhkl0228 </groupId> <artifactId> < version > 0.9.0 < / version > < / dependency > < the dependency > < groupId > com. Making. Zhkl0228 < / groupId > </artifactId> unidbg-android</artifactId> </version> 0.9.0</version> </dependency> <groupId> <artifactId>unidbg</artifactId> <version>0.9.5</version> <scope>system</scope> <systemPath>${project.basedir}/libs/unidbg-parent.jar</systemPath> </dependency>Copy the code
  • Then right-click Maven -> Reload Project in the left project window

  • Let’s recompile. Wrong. I knew it wouldn’t go so well.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instanceiate [. Com. Damei. XHS xhsshield. Controller. Xhs668Controller] : constructor throws an exception. Nested exception is Java. Lang. NoSuchFieldError: OSX_ARM64 at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:225) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) at org .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFac tory.java:1308) ... 18 more cause: Java. Lang. NoSuchFieldError: OSX_ARM64Copy the code
  • Why is that? I can’t believe it. Forget Google.

One of Unidbg’s friends on Github asked about issues, which are similar to the issues we encountered. The author has no solution yet. But this man said: I used the previous 0.9.2 did not have this problem, 0.9.3 appeared this problem

Take a closer look at the unidbg-server author’s gameplay. He uses version 0.9.0 of Unidbg.

Well, the quick fix for now is to download the 0.9.2 Unidbg code back and add our custom code. Let me compile it again, and I ran it.

A little slow? One more optimization

The performance bottleneck in the production environment may be in the simulator initialization of UnIDBG. We can only initialize one emulator and then only call the specified function each time we sign.

Create a fenfeicontroller.java in the Controller directory

public class FenfeiController { public static DouyinSign instance; static { instance = new DouyinSign(); } @RequestMapping(value="dySignEx",method = {RequestMethod.GET,RequestMethod.POST}) @ResponseBody public String dySign(@RequestParam("url") String url) { Map<String,String> result= instance.crack(url); String jsonString = JSON.toJSONString(result); return jsonString; }}Copy the code

This only initializes the simulator once, so it feels faster.

However, it introduces a new problem, emulators are shared, concurrency can be a problem, this is not a problem, we just put a lock

public String dySign(@RequestParam("url") String url) { synchronized (this) { Map<String, String> result = instance.crack(url); String jsonString = JSON.toJSONString(result); return jsonString; }}Copy the code

Finish it off. Serve the fresh beer.

Third, summary

You can change the address and port of the service by yourself using application.properties. So far, I have only changed the port and left the IP address 0.0.0.0.

Version matching is also important for open source programs. If you find incompatibilities with the latest code, look for a version or two to roll back.

It’s available out of the box. It’s the work of the big boys. But we can’t just use it out of the box. We need to understand the general principles. Otherwise, a little customization would have caught you.

Unidbg – server compiled into a jar package, please refer to the 91 fans.com.cn/post/unidbg…

We are born wandering

TIP: The purpose of this article is only one is learning more backward techniques and train of thought, if anyone use this technology to get illegal commercial interests the legal liabilities are their operators, and the author and it doesn’t matter, this paper involves the knowledge of code project can go to my friends to fly star come undone, welcome to join star learn together to explore technology knowledge. Questions can be added to me WX: Fenfei331 discussion.

Wechat public account: Fenfei security, the latest technology dry goods real-time push