Par discrétion je cache le nom de celui qui me l'a envoyé, il se reconnaitra. Je vous mets la copie d'un post d'********* concernant la recherche de 9c et 15c.
:
j'ai des morceaux de codes en java pour faire cela
L'auteur me
l'avait refilé, il l'utilisait lui à partir d'un intranet avec proxy etc.
Il
est donc à modifier legerement mais je suis pas assez bon en programmation,
notament tout ce qui est reseau et je m'y suis jamais plongé pour
l'utiliser
D'ailleurs, ne pas oublier que c'est totalement interdit à
utiliser et je conseille donc de l'utiliser d'un compte sur le serveur 15 créé
expres pour cela et si possible avec une IP non commune à aucun autre
compte
Notes : nomdulogin et votremotdepasse sont biensûr à remplir
le
champ int loc = 149290; est le lieu de départ de recherche du 15C. C'est le
numéro que l'on voit comme adresse de lien lorsque l'n est sur la carte à
l'endoit voulu
Si je me souviens bien, le programme procede par recherche
systématique en spirale jusqu'à 40 cases du champ initial de 9C et 15C dont il
stock les coordonnées dans un cookies.
Pour les motivés, faites chauffer
eclipse :
import java.io.ByteArrayOutputStream;
import
java.io.DataInputStream;
import java.io.DataOutputStream;
import
java.io.FileOutputStream;
import java.io.IOException;
import
java.net.HttpURLConnection;
import java.net.URL;
import
java.net.URLConnection;
import java.net.URLEncoder;
import
java.security.MessageDigest;
import
java.security.NoSuchAlgorithmException;
import
java.text.DateFormat;
import java.text.SimpleDateFormat;
import
java.util.ArrayList;
import java.util.Date;
import
java.util.HashMap;
import java.util.Iterator;
import
java.util.Map;
import java.util.Properties;
import
java.util.StringTokenizer;
/**
* @author
LENEVEUT-99999
*
*/
public class Test {
public static void
main(String[] args) {
String begin =
"http://s7.travian.fr/karte.php?d=";
// PROXY
Properties
systemSettings =
System.getProperties();
systemSettings.put("http.proxyHost","proxy.cessi.cnamts.fr")
;
systemSettings.put("http.proxyPort", "390") ;
URL u =
null;
HttpURLConnection con = null;
sun.misc.BASE64Encoder encoder = new
sun.misc.BASE64Encoder();
String encodedUserPwd =
encoder.encode("LENEVEUT-99999:SIEGE".getBytes());
encodedUserPwd = "Basic "
+ encodedUserPwd;
Test cm = new Test();
try {
u = new
URL("http://s15.travian.fr/dorf1.php?login=4113&name05dc4=nomdulogin&pw05dc4=votremotdepasse");
con
= (HttpURLConnection)
u.openConnection();
con.setRequestProperty("Proxy-Authorization",
encodedUserPwd);
// PROXY ----------
con.setDoInput (true);
// Let the
RTS know that we want to do output.
con.setDoOutput (true);
// No caching,
we want the real thing.
con.setUseCaches (false);
// Specify the content
type.
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// Send POST
output.
DataOutputStream printout = new
DataOutputStream(con.getOutputStream());
String content = "login=" +
URLEncoder.encode("4113") + "&name05dc4=" + URLEncoder.encode ("nomdulogin")
+ "&pw05dc4=" + URLEncoder.encode ("votremotdepasse") +
"&autologin=ja";
printout.writeBytes (content);
printout.flush
();
printout.close ();
DataInputStream input = new DataInputStream
(con.getInputStream ());
String str;
/*while (null != ((str =
input.readLine())))
{
System.out.println
(str);
}*/
input.close
();
cm.storeCookies(con);
con.disconnect();
System.out.println(cm);
}
catch (Exception e) {
e.printStackTrace();
}
ArrayList c9 = new
ArrayList();
ArrayList c15 = new ArrayList();
int loc = 149290;
for(int i=0;i<50;i++) {
System.out.println(i);
for(int
j=(loc-(512*i));j<(loc+50-(512*i));j++) {
http://System.out.println("Loc :
"+j);
//long beg = System.currentTimeMillis();
try {
DataInputStream di
= null;
FileOutputStream fo = null;
byte [] b = new byte[4096];
u =
new URL(begin+j);
con = (HttpURLConnection)
u.openConnection();
cm.setCookies(con);
con.setRequestProperty("Proxy-Authorization",
encodedUserPwd);
// PROXY ----------
con.connect();
di = new
DataInputStream(con.getInputStream());
ByteArrayOutputStream out = new
ByteArrayOutputStream();
for (int
read=0;(read=di.read(b))!=-1;out.write(b,0,read));
http://System.out.println(out.toString());http://System.out.println("Connexion : "+(System.currentTimeMillis()-beg));
//beg =
System.currentTimeMillis();
String content =
out.toString();
if(content.indexOf("Mot de passe")!=-1)
{
System.out.println("Connexion
perdue");
System.out.println("******************* 9C
*******************");
for (Iterator iter = c9.iterator(); iter.hasNext()
{
String element = (String)
iter.next();
System.out.println(element);
}
System.out.println("
");
System.out.println("******************* 15C *******************");
for
(Iterator iter = c15.iterator(); iter.hasNext()
{
String element = (String)
iter.next();
System.out.println(element);
}
return;
}
if(content.indexOf("Plaine
délaissée")!=-1) {
String coord = content.substring(content.indexOf("Plaine
délaissée")+17, content.indexOf(")", content.indexOf("Plaine
délaissée"))+1);
int cer = 0;
int count = 0;
while((cer =
content.indexOf("img/fr/g/4/r4_0.gif")) !=-1) {
count++;
content =
content.substring(cer+20, content.length());
}
if(count==9)
{
c9.add(begin+j+coord);
}
if(count==15)
{
c15.add(begin+j+coord);
}
}
/*while(-1 != di.read(b,0,1000))
{
System.out.print(new String(b));
}*/
http://System.out.println("Parsing :
"+(System.currentTimeMillis()-beg));
con.disconnect();
} catch (Exception
e) {
con.disconnect();
e.printStackTrace();
}
/*try {
Properties
properties = System.getProperties();
properties.put("http.proxyHost",
"proxy5.cnamts.fr");
properties.put("http.proxyPort",
"390");
System.setProperties(properties);
URL url = new
URL(begin+i);
//URLConnection connection = url.openConnection();
//String
login = "LENEVEUT-99999:SIEGE";
//String encodedLogin =
Base64.encode(login.getBytes());
http://connection.setRequestProperty("Proxy-Authorization", "Basic " + encodedLogin);
System.setProperty
("http.proxyUserName","LENEVEUT-99999");
System.setProperty
("http.proxyPassword","je censure ici");
InputStream in = new
BufferedInputStream(url.openStream());
ByteArrayOutputStream out = new
ByteArrayOutputStream();
byte[] buffer = new byte[4096];
for (int
read=0;(read=in.read(buffer))!=-1;out.write(buffer,0,read));
System.out.println(out.toString());
}
catch(Exception e)
{
e.printStackTrace();
}*/
}
}
System.out.println("*******************
9C *******************");
for (Iterator iter = c9.iterator();
iter.hasNext()
{
String element = (String)
iter.next();
System.out.println(element);
}
System.out.println("
");
System.out.println("******************* 15C *******************");
for
(Iterator iter = c15.iterator(); iter.hasNext()
{
String element = (String)
iter.next();
System.out.println(element);
}
}
private Map store
= new HashMap();
private static final String SET_COOKIE =
"Set-Cookie";
private static final String COOKIE_VALUE_DELIMITER =
";";
private static final String PATH = "path";
private static final
String EXPIRES = "expires";
private static final String DATE_FORMAT = "EEE,
dd-MMM-yyyy hh
ss z";
private static final String SET_COOKIE_SEPARATOR=";
";
private static final String COOKIE = "Cookie";
private static final
char NAME_VALUE_SEPARATOR = '=';
private static final char DOT =
'.';
private DateFormat dateFormat = new
SimpleDateFormat(DATE_FORMAT);
/**
* Retrieves and stores cookies
returned by the host on the other side
* of the the open
java.net.URLConnection.
*
* The connection MUST have been opened using the
connect()
* method or a IOException will be thrown.
*
* @param conn a
java.net.URLConnection - must be open, or IOException will be thrown
*
@throws java.io.IOException Thrown if conn is not open.
*/
public void
storeCookies(URLConnection conn) throws IOException {
// let's determine
the domain from where these cookies are being sent
String domain =
getDomainFromHost(conn.getURL().getHost());
Map domainStore; // this
is where we will store cookies for this domain
// now let's check the
store to see if we have an entry for this domain
if
(store.containsKey(domain)) {
// we do, so lets retrieve it from the
store
domainStore = (Map)store.get(domain);
} else {
// we don't, so
let's create it and put it in the store
domainStore = new
HashMap();
store.put(domain, domainStore);
}
// OK,
now we are ready to get the cookies out of the URLConnection
String
headerName=null;
for (int i=1; (headerName = conn.getHeaderFieldKey(i)) !=
null; i++) {
if (headerName.equalsIgnoreCase(SET_COOKIE)) {
Map cookie =
new HashMap();
StringTokenizer st = new
StringTokenizer(conn.getHeaderField(i), COOKIE_VALUE_DELIMITER);
// the
specification dictates that the first name/value pair
// in the string is the
cookie name and value, so let's handle
// them as a special case:
if
(st.hasMoreTokens()) {
String token = st.nextToken();
String name =
token.substring(0, token.indexOf(NAME_VALUE_SEPARATOR));
String value =
token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1,
token.length());
domainStore.put(name, cookie);
cookie.put(name,
value);
}
while (st.hasMoreTokens()) {
String token =
st.nextToken();
cookie.put(token.substring(0,
token.indexOf(NAME_VALUE_SEPARATOR)).toLowerCase(),
token.substring(token.indexOf(NAME_VALUE_SEPARATOR)
+ 1, token.length()));
}
}
}
}
/**
* Prior to opening
a URLConnection, calling this method will set all
* unexpired cookies that
match the path or subpaths for thi underlying URL
*
* The connection MUST
NOT have been opened
* method or an IOException will be thrown.
*
*
@param conn a java.net.URLConnection - must NOT be open, or IOException will be
thrown
* @throws java.io.IOException Thrown if conn has already been
opened.
*/
public void setCookies(URLConnection conn) throws IOException
{
// let's determine the domain and path to retrieve the appropriate
cookies
URL url = conn.getURL();
String domain =
getDomainFromHost(url.getHost());
String path = url.getPath();
Map
domainStore = (Map)store.get(domain);
if (domainStore == null)
return;
StringBuffer cookieStringBuffer = new StringBuffer();
Iterator
cookieNames = domainStore.keySet().iterator();
while(cookieNames.hasNext())
{
String cookieName = (String)cookieNames.next();
Map cookie =
(Map)domainStore.get(cookieName);
// check cookie to ensure path matches and
cookie is not expired
// if all is cool, add cookie to header string
if
(comparePaths((String)cookie.get(PATH), path) &&
isNotExpired((String)cookie.get(EXPIRES)))
{
cookieStringBuffer.append(cookieName);
cookieStringBuffer.append("=");
cookieStringBuffer.append((String)cookie.get(cookieName));
if
(cookieNames.hasNext())
cookieStringBuffer.append(SET_COOKIE_SEPARATOR);
}
}
try
{
conn.setRequestProperty(COOKIE, cookieStringBuffer.toString());
} catch
(java.lang.IllegalStateException ise) {
IOException ioe = new
IOException("Illegal State! Cookies cannot be set on a URLConnection that is
already connected. "
+ "Only call setCookies(java.net.URLConnection) AFTER
calling java.net.URLConnection.connect().");
throw
ioe;
}
}
private String getDomainFromHost(String host) {
if
(host.indexOf(DOT) != host.lastIndexOf(DOT)) {
return
host.substring(host.indexOf(DOT) + 1);
} else {
return
host;
}
}
private boolean isNotExpired(String cookieExpires)
{
if (cookieExpires == null) return true;
Date now = new Date();
try
{
return (now.compareTo(dateFormat.parse(cookieExpires))) <= 0;
} catch
(java.text.ParseException pe) {
pe.printStackTrace();
return
false;
}
}
private boolean comparePaths(String cookiePath, String
targetPath) {
if (cookiePath == null) {
return true;
} else if
(cookiePath.equals("/")) {
return true;
} else if
(targetPath.regionMatches(0, cookiePath, 0, cookiePath.length())) {
return
true;
} else {
return false;
}
}
private static String
encodeMD5(String key) {
byte[] uniqueKey = key.getBytes();
byte[] hash
= null;
try {
//on récupère un objet qui permettra de crypter la
chaine
hash = MessageDigest.getInstance("MD5").digest(uniqueKey);
} catch
(NoSuchAlgorithmException e) {
e.printStackTrace();
}
StringBuffer
hashString = new StringBuffer(50);
for (int i = 0; i < hash.length; ++i)
{
String hex = Integer.toHexString(hash[i]);
if (hex.length() == 1)
{
hashString.append('0');
hashString.append(hex.charAt(hex.length() -
1));
} else {
hashString.append(hex.substring(hex.length() -
2));
}
}
return hashString.toString();
}
}
je viens de
voir qu'il y'a encore des URL du genre s7.travian.fr à remplacer par
s15.travian.fr etc..
Bref, c'est une base mais y'a des modifs à faire dessus