Thread: Cache downloader patch

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1. #11  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Goodjob
    Attached image
    Attached image
    Reply With Quote  
     

  2. #12  
    Registered Member
    excl150's Avatar
    Join Date
    Jul 2014
    Posts
    123
    Thanks given
    46
    Thanks received
    30
    Rep Power
    97
    Quote Originally Posted by lumplum View Post
    Thanks for this
    No problem

    Quote Originally Posted by _jordan View Post
    Goodjob
    Thanks
    Reply With Quote  
     

  3. #13  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Posts
    2,622
    Thanks given
    201
    Thanks received
    813
    Rep Power
    1462
    To have musics download you need to update the URL in HttpWorker.java

    It was
    Code:
    url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    It should be

    Code:
    url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&k="+major+"&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    You need to add:
    Code:
    	/**
    	 * Gets the current major version for inclusion with Http requestions.
    	 * @Return The major version.
    	 */
    	public int getMajor() {
    		return major;
    	}
    to Js5Worker.

    and
    Code:
    	private int major;
    
    	/**
    	 * Sets the current major version for inclusion with Http requests.
    	 * @Param major the version.
    	 */
    	public void setMajor(int major) {
    		this.major = major;		
    	}
    to HttpWorker

    also add
    Code:
    		httpWorker.setMajor(js5Worker.getMajor());
    as the first line in the CacheDownloader.update() method.

    (Alternatively, you could just edit the URL to be Js5Worker.major and then change that value to public static)...
    Quote Originally Posted by blakeman8192 View Post
    Quitting is the only true failure.
    Reply With Quote  
     

  4. Thankful users:


  5. #14  
    Registered Member
    excl150's Avatar
    Join Date
    Jul 2014
    Posts
    123
    Thanks given
    46
    Thanks received
    30
    Rep Power
    97
    Quote Originally Posted by Advocatus View Post
    To have musics download you need to update the URL in HttpWorker.java

    It was
    Code:
    url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    It should be

    Code:
    url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&k="+major+"&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    You need to add:
    Code:
    	/**
    	 * Gets the current major version for inclusion with Http requestions.
    	 * @Return The major version.
    	 */
    	public int getMajor() {
    		return major;
    	}
    to Js5Worker.

    and
    Code:
    	private int major;
    
    	/**
    	 * Sets the current major version for inclusion with Http requests.
    	 * @Param major the version.
    	 */
    	public void setMajor(int major) {
    		this.major = major;		
    	}
    to HttpWorker

    also add
    Code:
    		httpWorker.setMajor(js5Worker.getMajor());
    as the first line in the CacheDownloader.update() method.

    (Alternatively, you could just edit the URL to be Js5Worker.major and then change that value to public static)...
    Nice work, thanks for sharing!
    Reply With Quote  
     

  6. #15  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,819
    Thanks received
    1,767
    Rep Power
    2438
    Good work! Keep it rolling
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  7. #16  
    Registered Member
    Join Date
    Feb 2021
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Code:
     C:\Users\####\Desktop\rscd>java -cp out com.method.rscd.CacheDownloader
    java.net.ConnectException: Connection timed out: connect
    What gives?
    Reply With Quote  
     

  8. #17  
    ᗪ乇尺乇乙乙乇ᗪ

    lumplum's Avatar
    Join Date
    Nov 2015
    Posts
    1,145
    Thanks given
    529
    Thanks received
    1,463
    Rep Power
    5000
    Quote Originally Posted by Advocatus View Post
    I had to change the URL used in the connect method to
    Code:
    String key = Crawler.extractParameter(Crawler.downloadPage("https://world21.runescape.com/j0"), 32);
    as per https://github.com/villermen/runesca...ientDetails.cs

    It wasn't extracting the key successfully.
    Previously the string was
    Code:
    "http://world" + WORLD + ".runescape.com/g=runescape/,j0"
    not working atm, is there an updated url?
    Attached image
    Reply With Quote  
     

  9. #18  
    Reverse Engineering

    freeezr's Avatar
    Join Date
    Dec 2011
    Posts
    1,067
    Thanks given
    288
    Thanks received
    444
    Rep Power
    401
    use the jav_config for getting the param

    Spoiler for rscd.patch:

    Code:
    diff -ruN rscd/src rscd_updated/src > rscd.patch
    Code:
    patch -p0 < rscd.patch
    Code:
    diff -ruN rscd/src/com/method/rscd/CacheDownloader.java rscd_updated/src/com/method/rscd/CacheDownloader.java
    --- rscd/src/com/method/rscd/CacheDownloader.java	2021-02-21 15:24:44.271341400 -0600
    +++ rscd_updated/src/com/method/rscd/CacheDownloader.java	2021-02-21 15:24:00.225333900 -0600
    @@ -23,10 +23,9 @@
      */
     public class CacheDownloader {
     
    -	private static final int MAJOR_VERSION = 892;
    +	private static final int MAJOR_VERSION = 917;
     	private static final int MINOR_VERSION = 1;
     	private static final String HOST = "content.runescape.com";
    -	private static final int WORLD = 2;
     	private static final int LANGUAGE = 0; // English language by default
     
     	private static final int MUSIC_INDEX = 40;
    @@ -55,7 +54,6 @@
     	 */
     	public CacheDownloader() {
     		js5Worker = new Js5Worker();
    -		httpWorker = new HttpWorker(HOST);
     	}
     
     	/**
    @@ -76,7 +74,7 @@
     	 * Connects to the server, retrying as needed if the version is incorrect.
     	 */
     	private void connect() {
    -		String key = Crawler.extractParameter(Crawler.downloadPage("http://world" + WORLD + ".runescape.com/g=runescape/,j0"), 32);
    +		String key = Crawler.extractParameter(Crawler.downloadPage("http://runescape.com/jav_config.ws?binaryType=2"), 32);
     		if (key == null) {
     			System.err.println("Couldn't find valid handshake key.");
     			System.exit(1);
    @@ -86,6 +84,8 @@
     			js5Worker.process();
     		}
     		System.out.println("Successful connection");
    +
    +		httpWorker = new HttpWorker(HOST, js5Worker.major);
     	}
     
     	/**
    diff -ruN rscd/src/com/method/rscd/net/HttpWorker.java rscd_updated/src/com/method/rscd/net/HttpWorker.java
    --- rscd/src/com/method/rscd/net/HttpWorker.java	2021-02-21 15:24:44.340341000 -0600
    +++ rscd_updated/src/com/method/rscd/net/HttpWorker.java	2020-09-19 18:20:08.279223300 -0500
    @@ -11,10 +11,12 @@
     public class HttpWorker {
     
     	private String host;
    +	private int major;
     	private ExecutorService executor;
     
    -	public HttpWorker(String host) {
    +	public HttpWorker(String host, int major) {
     		this.host = host;
    +		this.major = major;
     		this.executor = Executors.newFixedThreadPool(2);
     	}
     
    @@ -43,7 +45,7 @@
     		public void run() {
     			URL url;
     			try {
    -				url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    +				url = new URL("http", host, 80, "/ms?m=0&k=" + major + "&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
     			} catch (MalformedURLException ex) {
     				return;
     			}
    diff -ruN rscd/src/com/method/rscd/net/Js5Worker.java rscd_updated/src/com/method/rscd/net/Js5Worker.java
    --- rscd/src/com/method/rscd/net/Js5Worker.java	2021-02-21 15:24:44.350342000 -0600
    +++ rscd_updated/src/com/method/rscd/net/Js5Worker.java	2020-11-03 15:22:23.403957300 -0600
    @@ -16,7 +16,7 @@
      */
     public class Js5Worker {
     
    -	public static final int LOADING_REQUIREMENTS = 27;
    +	public static final int LOADING_REQUIREMENTS = 28;
     	public static final int BLOCK_SIZE = 102400;
     
     	public enum State {
    @@ -30,7 +30,7 @@
     	private OutputStream output;
     	private State state;
     	private String host;
    -	private int major;
    +	public int major;
     	private int minor;
     	private String key;
     	private int language;
    @@ -46,7 +46,7 @@
     		requests = new LinkedList<FileRequest>();
     		waiting = new HashMap<Long, FileRequest>();
     		state = State.DISCONNECTED;
    -		outputBuffer = ByteBuffer.allocate(6);
    +		outputBuffer = ByteBuffer.allocate(10);
     		inputBuffer = ByteBuffer.allocate(5);
     	}
     
    @@ -175,6 +175,7 @@
     					outputBuffer.put(request.getIndex() == 255 ? (byte) 1 : (byte) 0);
     					outputBuffer.put((byte) request.getIndex());
     					outputBuffer.putInt(request.getFile());
    +					putFooter(outputBuffer);
     					output.write(outputBuffer.array());
     					output.flush();
     					outputBuffer.clear();
    @@ -259,8 +260,9 @@
     	private void sendConnectionInfo() {
     		try {
     			outputBuffer.put((byte) 6);
    -			putMedInt(outputBuffer, 4);
    +			putMedInt(outputBuffer, 5);
     			outputBuffer.putShort((short) 0);
    +			putFooter(outputBuffer);
     			output.write(outputBuffer.array());
     			output.flush();
     			outputBuffer.clear();
    @@ -268,6 +270,7 @@
     			outputBuffer.put((byte) 3);
     			putMedInt(outputBuffer, 0);
     			outputBuffer.putShort((short) 0);
    +			putFooter(outputBuffer);
     			output.write(outputBuffer.array());
     			output.flush();
     			outputBuffer.clear();
    @@ -299,6 +302,16 @@
     	}
     
     	/**
    +	 * Helper method to put the footer of the js5 packets
    +	 *
    +	 *   @Param buffer The buffer
    +	 */
    +	private void putFooter(ByteBuffer buffer) {
    +		buffer.putShort((short) major);
    +		buffer.putShort((short) 0);
    +	}
    +
    +	/**
     	 * Helper method to put a three-byte value into a buffer.
     	 *
     	 *   @Param buffer The buffer
    diff -ruN rscd/src/com/method/rscd/util/Crawler.java rscd_updated/src/com/method/rscd/util/Crawler.java
    --- rscd/src/com/method/rscd/util/Crawler.java	2021-02-21 15:24:44.368341500 -0600
    +++ rscd_updated/src/com/method/rscd/util/Crawler.java	2021-02-21 15:23:00.967993100 -0600
    @@ -5,12 +5,14 @@
     import java.io.InputStreamReader;
     import java.net.MalformedURLException;
     import java.net.URL;
    +import java.util.ArrayList;
    +import java.util.List;
     import java.util.regex.Matcher;
     import java.util.regex.Pattern;
     
     public class Crawler {
     
    -	public static String downloadPage(String address) {
    +	public static List<String> downloadPage(String address) {
     		URL url;
     		try {
     			url = new URL(address);
    @@ -21,29 +23,34 @@
     
     		try {
     			BufferedReader reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
    -			StringBuilder page = new StringBuilder();
    +			List<String> page = new ArrayList<>();
     			String line;
     			while ((line = reader.readLine()) != null) {
    -				page.append(line);
    +				page.add(line);
     			}
    -			return page.toString();
    +			return page;
     		} catch (IOException ex) {
     			ex.printStackTrace();
     			return null;
     		}
     	}
     
    -	public static String extractParameter(String input, int length) {
    +	public static String extractParameter(List<String> input, int length) {
     		if (input == null) {
     			return null;
     		}
    -		Pattern p = Pattern.compile("value=\"(\\S{" + length + "})\"");
    -		Matcher m = p.matcher(input);
    -		if (m.find()) {
    -			return m.group(1);
    -		} else {
    -			return null;
    +
    +		Pattern p = Pattern.compile("=\\S{1,2}=(\\S{" + length + "})$");
    +		for (String line : input) {
    +			if (line.startsWith("param=")) {
    +				Matcher m = p.matcher(line);
    +				if (m.find()) {
    +					return m.group(1);
    +				}
    +			}
     		}
    +
    +		return null;
     	}
     
     }

    Attached image
    Reply With Quote  
     

  10. #19  
    Registered Member
    Join Date
    Apr 2012
    Posts
    23
    Thanks given
    1
    Thanks received
    2
    Rep Power
    44
    Quote Originally Posted by freeezer View Post
    use the jav_config for getting the param

    Spoiler for rscd.patch:

    Code:
    diff -ruN rscd/src rscd_updated/src > rscd.patch
    Code:
    patch -p0 < rscd.patch
    Code:
    diff -ruN rscd/src/com/method/rscd/CacheDownloader.java rscd_updated/src/com/method/rscd/CacheDownloader.java
    --- rscd/src/com/method/rscd/CacheDownloader.java	2021-02-21 15:24:44.271341400 -0600
    +++ rscd_updated/src/com/method/rscd/CacheDownloader.java	2021-02-21 15:24:00.225333900 -0600
    @@ -23,10 +23,9 @@
      */
     public class CacheDownloader {
     
    -	private static final int MAJOR_VERSION = 892;
    +	private static final int MAJOR_VERSION = 917;
     	private static final int MINOR_VERSION = 1;
     	private static final String HOST = "content.runescape.com";
    -	private static final int WORLD = 2;
     	private static final int LANGUAGE = 0; // English language by default
     
     	private static final int MUSIC_INDEX = 40;
    @@ -55,7 +54,6 @@
     	 */
     	public CacheDownloader() {
     		js5Worker = new Js5Worker();
    -		httpWorker = new HttpWorker(HOST);
     	}
     
     	/**
    @@ -76,7 +74,7 @@
     	 * Connects to the server, retrying as needed if the version is incorrect.
     	 */
     	private void connect() {
    -		String key = Crawler.extractParameter(Crawler.downloadPage("http://world" + WORLD + ".runescape.com/g=runescape/,j0"), 32);
    +		String key = Crawler.extractParameter(Crawler.downloadPage("http://runescape.com/jav_config.ws?binaryType=2"), 32);
     		if (key == null) {
     			System.err.println("Couldn't find valid handshake key.");
     			System.exit(1);
    @@ -86,6 +84,8 @@
     			js5Worker.process();
     		}
     		System.out.println("Successful connection");
    +
    +		httpWorker = new HttpWorker(HOST, js5Worker.major);
     	}
     
     	/**
    diff -ruN rscd/src/com/method/rscd/net/HttpWorker.java rscd_updated/src/com/method/rscd/net/HttpWorker.java
    --- rscd/src/com/method/rscd/net/HttpWorker.java	2021-02-21 15:24:44.340341000 -0600
    +++ rscd_updated/src/com/method/rscd/net/HttpWorker.java	2020-09-19 18:20:08.279223300 -0500
    @@ -11,10 +11,12 @@
     public class HttpWorker {
     
     	private String host;
    +	private int major;
     	private ExecutorService executor;
     
    -	public HttpWorker(String host) {
    +	public HttpWorker(String host, int major) {
     		this.host = host;
    +		this.major = major;
     		this.executor = Executors.newFixedThreadPool(2);
     	}
     
    @@ -43,7 +45,7 @@
     		public void run() {
     			URL url;
     			try {
    -				url = new URL("http", host, 80, "/ms?m=0&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
    +				url = new URL("http", host, 80, "/ms?m=0&k=" + major + "&a=" + request.getIndex() + "&g=" + request.getFile() + "&c=" + crc + "&v=" + version);
     			} catch (MalformedURLException ex) {
     				return;
     			}
    diff -ruN rscd/src/com/method/rscd/net/Js5Worker.java rscd_updated/src/com/method/rscd/net/Js5Worker.java
    --- rscd/src/com/method/rscd/net/Js5Worker.java	2021-02-21 15:24:44.350342000 -0600
    +++ rscd_updated/src/com/method/rscd/net/Js5Worker.java	2020-11-03 15:22:23.403957300 -0600
    @@ -16,7 +16,7 @@
      */
     public class Js5Worker {
     
    -	public static final int LOADING_REQUIREMENTS = 27;
    +	public static final int LOADING_REQUIREMENTS = 28;
     	public static final int BLOCK_SIZE = 102400;
     
     	public enum State {
    @@ -30,7 +30,7 @@
     	private OutputStream output;
     	private State state;
     	private String host;
    -	private int major;
    +	public int major;
     	private int minor;
     	private String key;
     	private int language;
    @@ -46,7 +46,7 @@
     		requests = new LinkedList<FileRequest>();
     		waiting = new HashMap<Long, FileRequest>();
     		state = State.DISCONNECTED;
    -		outputBuffer = ByteBuffer.allocate(6);
    +		outputBuffer = ByteBuffer.allocate(10);
     		inputBuffer = ByteBuffer.allocate(5);
     	}
     
    @@ -175,6 +175,7 @@
     					outputBuffer.put(request.getIndex() == 255 ? (byte) 1 : (byte) 0);
     					outputBuffer.put((byte) request.getIndex());
     					outputBuffer.putInt(request.getFile());
    +					putFooter(outputBuffer);
     					output.write(outputBuffer.array());
     					output.flush();
     					outputBuffer.clear();
    @@ -259,8 +260,9 @@
     	private void sendConnectionInfo() {
     		try {
     			outputBuffer.put((byte) 6);
    -			putMedInt(outputBuffer, 4);
    +			putMedInt(outputBuffer, 5);
     			outputBuffer.putShort((short) 0);
    +			putFooter(outputBuffer);
     			output.write(outputBuffer.array());
     			output.flush();
     			outputBuffer.clear();
    @@ -268,6 +270,7 @@
     			outputBuffer.put((byte) 3);
     			putMedInt(outputBuffer, 0);
     			outputBuffer.putShort((short) 0);
    +			putFooter(outputBuffer);
     			output.write(outputBuffer.array());
     			output.flush();
     			outputBuffer.clear();
    @@ -299,6 +302,16 @@
     	}
     
     	/**
    +	 * Helper method to put the footer of the js5 packets
    +	 *
    +	 *   @Param buffer The buffer
    +	 */
    +	private void putFooter(ByteBuffer buffer) {
    +		buffer.putShort((short) major);
    +		buffer.putShort((short) 0);
    +	}
    +
    +	/**
     	 * Helper method to put a three-byte value into a buffer.
     	 *
     	 *   @Param buffer The buffer
    diff -ruN rscd/src/com/method/rscd/util/Crawler.java rscd_updated/src/com/method/rscd/util/Crawler.java
    --- rscd/src/com/method/rscd/util/Crawler.java	2021-02-21 15:24:44.368341500 -0600
    +++ rscd_updated/src/com/method/rscd/util/Crawler.java	2021-02-21 15:23:00.967993100 -0600
    @@ -5,12 +5,14 @@
     import java.io.InputStreamReader;
     import java.net.MalformedURLException;
     import java.net.URL;
    +import java.util.ArrayList;
    +import java.util.List;
     import java.util.regex.Matcher;
     import java.util.regex.Pattern;
     
     public class Crawler {
     
    -	public static String downloadPage(String address) {
    +	public static List<String> downloadPage(String address) {
     		URL url;
     		try {
     			url = new URL(address);
    @@ -21,29 +23,34 @@
     
     		try {
     			BufferedReader reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
    -			StringBuilder page = new StringBuilder();
    +			List<String> page = new ArrayList<>();
     			String line;
     			while ((line = reader.readLine()) != null) {
    -				page.append(line);
    +				page.add(line);
     			}
    -			return page.toString();
    +			return page;
     		} catch (IOException ex) {
     			ex.printStackTrace();
     			return null;
     		}
     	}
     
    -	public static String extractParameter(String input, int length) {
    +	public static String extractParameter(List<String> input, int length) {
     		if (input == null) {
     			return null;
     		}
    -		Pattern p = Pattern.compile("value=\"(\\S{" + length + "})\"");
    -		Matcher m = p.matcher(input);
    -		if (m.find()) {
    -			return m.group(1);
    -		} else {
    -			return null;
    +
    +		Pattern p = Pattern.compile("=\\S{1,2}=(\\S{" + length + "})$");
    +		for (String line : input) {
    +			if (line.startsWith("param=")) {
    +				Matcher m = p.matcher(line);
    +				if (m.find()) {
    +					return m.group(1);
    +				}
    +			}
     		}
    +
    +		return null;
     	}
     
     }
    hey i done the patch but having loading element sizes error trying download 917cache, https://gyazo.com/1f510bfab8fc8c0acd03732713fde129
    Reply With Quote  
     

  11. #20  
    Registered Member
    Join Date
    Apr 2015
    Posts
    42
    Thanks given
    3
    Thanks received
    0
    Rep Power
    0
    Must have changed the location for their cache. Cause this can't connect a valid handshake anymore lol. They try hard to stop their content from being ripped.
    Reply With Quote  
     

Page 2 of 3 FirstFirst 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Auto Cache Downloading
    By James in forum Tutorials
    Replies: 113
    Last Post: 09-27-2008, 04:25 PM
  2. Auto Cache Downloading (Here's how!)
    By Ninja Cat in forum Tutorials
    Replies: 22
    Last Post: 03-11-2008, 02:50 PM
  3. 417 cache download!
    By Mr.Andrew Gover in forum RS2 Client
    Replies: 14
    Last Post: 12-15-2007, 07:25 PM
  4. Auto Cache download?
    By Eportal in forum Tutorials
    Replies: 4
    Last Post: 10-07-2007, 06:34 PM
  5. Buying Auto cache downloading webclient
    By wildy in forum RS2 Client
    Replies: 2
    Last Post: 08-24-2007, 03:40 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •