Rating:

after analyzing the given code source, we see that "p" and "h" are unchangable.
So, we should look for them in the first place.
To find "p" and "h":
simply, we we use the "test mode". Here, we can enter "m" for 2 times. So firstly, we send "0", and for the second time we send "10^21", here we obtain to numbers c1, and c2. we should repeat this step until we got c2>c1. and here we can say that: p=10^21+c1-c2
```
import socket
import time
hote = "random2win.acebear.site"
port = 33337
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((hote, port))
m=socket.recv(1024)
m=socket.recv(1024)
socket.send(str(1))
m=socket.recv(1024)
socket.send("\x00")
m=socket.recv(1024)
print m
p=int("1"+"0"*120)
socket.send(hex(p).strip("L")[2:].decode("hex"))
m=socket.recv(1024)
print m

print "Close"
socket.close()
```
To get "h", I used a script that I lost :'( . To do it, I send to server two times "0", so I got r1*h%p and r2*h%p. then I cryete a list, were I puted L1=[i*(r1*h)%p for i in list_of_the_inverse_off_element_2_to_222222], and L2=[i*(r2*h)%p for i in list_of_the_inverse_off_element_2_to_222222]. So the only element that while be in the two list is "h".
So we get :
#p=2129236650498506197214865121017813676962270980934541379925587741818174020229784960110052122450619093813474017151250421361
#h=11305546770736405378819894875529407145124231011999396912086973074056791191623579252993880901245430834195596982773094L

Know we have "p" and "h", so we can attaque the real probleme to find "m".
Here I used a little script for brute foncing (I used the fact that 10**10<=r<=10**12 and 10**10<=m<=10**12 in order to find the break):
```
#nc random2win.acebear.site 33337
import socket
import time
hote = "random2win.acebear.site"

port = 33337
h=11305546770736405378819894875529407145124231011999396912086973074056791191623579252993880901245430834195596982773094L
p=2129236650498506197214865121017813676962270980934541379925587741818174020229784960110052122450619093813474017151250421361

socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((hote, port))
m=socket.recv(1024)
m=socket.recv(1024)
socket.send(str(2))
m=socket.recv(1024)
c=int(m.split()[-1])
n=c+10**4*p*5
while n<h*10**12:
r=n/h
m=n%h
if r>=10**10 and m>=10**10 and m<=10**12:
print r,m,(r*h+m)%p
break
n+=p
socket.send(str(m))
print socket.recv(1024)

print "Close"
socket.close()
```

So we got our flag :)