Probably the easiest way to do this, if you don't have any special tools, is run
plex under the control of
gdb, with the input of
gdb comping from a script. To do that, you need to find the address where 32400 is hardcoded.
objdump -D plex | grep -i 7e90
should give you something like
40090b: bf 90 7e 00 00 mov $0x7e90,%edi
Start gdb, set a breakpoint there, run the program until it hits the breakpoint.
Step one instruction, change the register value, and continue running the program:
>> 0x0000000000400910 in main () <-- address of next instruction
info registers <-- just to make sure
>> rdi 0x7e90 32400
set $rdi=0x7e91 <-- patch the value
info registers <-- again, just to make sure
>> rdi 0x7e91 32401
In a different window, check if plex really listens on the other port:
netstat -ntap | grep plex
tcp 0 0 0.0.0.0:32401 0.0.0.0:* LISTEN 22018/plex
yes it did!
Now automate this in a script:
gdb plex <<EOF
break *0x400910 <-- note this is the instruction AFTER the load, not the one we breaked on last time
and run that script instead of
plex everytime you want to start it on a different port.
Of course, you could also use a hex editor to change the value in the binary directly. You'll even have to do this if the routine that sets up the listening port gets called repeatedly (so you can't predict which exact input gdb needs). However, in many cases, this might be the easiest method, since it doesn't require changing the binary or programming a LD_PRELOAD handler, and changing the port number later is super-easy.