Question Linux: redirecting dead URLs hardcoded into program binaries

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,038
Reaction score
1,275
Points
188
Location
Dallas, TX
A certain program that I use downloads data from a server maintained by another party than the application developer, and is somewhat crippled if that data is not available. The problem is that the developer of this application (whose name will be withheld to protect the guilty) hardcoded the URL into the binary, and the party that maintains the server that the application gets its data from recently changed the hostname and directory structure of their server, which breaks the hardcoded URL and cripples the program.

No updates are forthcoming from the developer, and no source code is available. The URL is broken into host and path components in separate strings in the binary, and the new host component is longer than the old one and is followed immediately by another string without any padding, so I can't hex-edit it into the binary without throwing off the relocations for variables in that part of the binary and breaking the whole program.

Does anybody have any recommendations on the best way to intercept the old URL coming out of the program and rewrite it into the new URL before the packet leaves my machine? I assume some sort of proxy solution would be involved, but I don't have a lot of experience with that sort of thing. I'm currently running Ubuntu 14.04.
 

tl8

Addon Developer
Addon Developer
Tutorial Publisher
Joined
Oct 16, 2007
Messages
3,645
Reaction score
25
Points
88
Location
Gold Coast QLD
Not particularly helpful but we had a client that wanted to change the destination of a QR code. As it was printed in a book, we couldn't really help her.
 

Ravenous

Donator
Donator
Joined
Jul 19, 2013
Messages
275
Reaction score
0
Points
0
Location
sitting at the pointy end
Download all the stuff you need - if this is possible - and put it onto your own server with a shorter URL and hack the binary to read that? (I have to go away and wash my hands now after typing such a dirty suggestion.)
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Orbiter Contributor
Addon Developer
Webmaster
GFX Staff
Beta Tester
Joined
Aug 9, 2009
Messages
6,929
Reaction score
795
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
Stand up a proxy server which obtains the content from the new remote location and presents it on the expected URL structure the old remote used to use, and use some devious tactics to trick your system into redirecting traffic destined for the old remote location onto this proxy server (hostname remapping, DNS foolery, whatever).

Since he used the hostname in the code, and you say in your title this is linux, then you can control how linux works out where the hostname maps to in /etc/nsswitch.conf - this says, usually:

Code:
hosts: files dns

Meaning that DNS results for foo.bar will be overridden by entries in /etc/hosts for foo.bar. If you're running your own local DNS, you could change it there, but the most straightforward approach is to add a line to /etc/hosts;

Code:
144.22.55.1     foo.bar

Squid is a pretty capable proxy server.
 
Top