View Single Post
  #24  
Old 01.08.2021, 04:17
artenox artenox is offline
I will play nice!
 
Join Date: Jul 2021
Posts: 1
Default

There are three ways to change User Agent.

1. Modify source code and compile your JDownloader build using Eclipse
The default User Agent is set in JDBrowser/src/jd/http/Request.java source code file
getSuggestedUserAgent() method
Instructions to compile https://jdownloader.org/knowledge/wi...nt/get-started
But it's pretty complicated (it didn't work for me) and you won't be able to get updates.
Instructions also don't tell you how to create a package (so you don't have to use Eclipse every time), it uses "ant" for that.
The size of source code is 1.4 GiB.
However you don't have to use your own build. You can try to take from it only one file JDHttp.jar which you need.

2. Modify binary code (patch/hack)
The default User Agent is located in file JDownloader/libs/JDHttp.jar and then after unpacking /jd/http/Request.class
JDHttp.jar is a zip archive. You can extract and add files to it using any archive manager (7Zip, WinRAR, Engrampa, etc).
Request.class is a binary file and should be edited in a binary editor (for example, Flexhex). Don't use a text editor, you can break.
Extract file Request.class, edit it and drag it back into archive.
But the length of User Agent cannot exceed the existing length. You won't be able to put a long User Agent (e.g. Chromium) without damaging it. In this case you will have to use method 1.
If the length of new User Agent is shorter, add spaces to it. Normal whitespaces (in binary representation 20 20), not null characters (00 00). Null characters are not allowed in that section.
You have to disable JDownloader updates (in advanced settings search for the word Update), otherwise file will be overwritten.
After each update, patching will have to be repeated. Although, you can create a script to automate it.

3. Use a local HTTPS proxy (aka MITM proxy)
The squid mentioned before is no longer relevant, since it doesn't support decrypting HTTPS traffic (which is predominant type on the Internet nowadays).
You can use HandyCache (there is an extension which lets you change User Agent, google it), Proximitron or Fiddler.
I personally tested HandyCache, it works. But the HTTPS decrypting feature is paid (free only first 30 minutes after each launch). And it is quite difficult to buy this program, especially for non-Russian users, although it is possible.
The disadvantage of this way: you have to use an additional program (and maybe more than one).
Advantage: you can continue to receive JDownloader updates, disable and change User Agent in realtime.
Proximitron is an old application and needs an addon to support HTTPS.
Local HTTPS proxies will most likely require a self-signed certificate to be installed on the system (this is not difficult). Although, I'm not sure, maybe JDownloader will work without it.
For Linux there is a console mitmproxy (python based, works by intercepting traffic with iptables). It supports changing User Agent but it's quite hard to configure, I guess. HandyCache is easier and works in Wine, but unfortunately free mode is limited.
Also note that not all of these proxies support upstream SOCKS proxy (in case you need it, of course).
SOCKS is supported in HandyCache. Not supported in: Proximitron, Fiddler, mitmproxy.
These proxy servers ignore HTTPS errors (e.g. outdated server certificate).

I personally use method 2.

Update: There is a class editor application for safe editing class files (requires Java installed on the system) **External links are only visible to Support Staff****External links are only visible to Support Staff**

Update 2 (mods, you can merge messages): Don't use class editor, it breaks file. Use a binary editor instead (Flexhex). But be careful. Don't modify characters that don't belong to User Agent. Make a backup.

Last edited by raztoki; 01.08.2021 at 16:45. Reason: user can't edit posts just yet, merging on behalf.
Reply With Quote