Skip to content

Instantly share code, notes, and snippets.

@seadog007
Last active January 31, 2019 06:53
Show Gist options
  • Save seadog007/1954d0265186335cf4e7be4a5ea19aff to your computer and use it in GitHub Desktop.
Save seadog007/1954d0265186335cf4e7be4a5ea19aff to your computer and use it in GitHub Desktop.
Fiddler extension for cracking Taiwan McDonald Coupon app which is available for both Android and iOS version (´・ω・`)
/*
======================
Author: 海豹
Date: 2017/1/22
Version: 1.0.0.0
Description: Fiddler extension for cracking Taiwan MacDonald Coupon app which is available for both Android and iOS version (´・ω・`)
僅供學術使用 請勿用作非法用途
======================
*/
import System;
import System.Windows.Forms;
import System.Random;
import Fiddler;
import Newtonsoft.Json.Linq;
var verified;
var today: Date = new Date();
var version = "1.0.0.0";
var coupon_list;
var RNG = new Random();
class Handlers
{
static function OnBeforeResponse(oSession: Session){
if (oSession.uriContains("/coupon") && verified == 1){
oSession.utilDecodeResponse();
var oJobject = new JObject;
var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
//=======================================================================
var ParseStatus = 0;
try
{
oJobject = JObject.Parse(oBody);
}
catch(e)
{
ParseStatus = 1;
oJobject = null;
}
if (ParseStatus == 1)
{
return ;
}
//=======================================================================
if (oSession.uriContains("/get_list")){
for (var id in coupon_list){
oJobject['results']['coupons'].Add(gencoupon(coupon_list[id], 1));
}
FiddlerApplication.Log.LogString('Coupon List request');
}
if (oSession.uriContains("/get_detail")){
oJobject["rc"] = 1;
oJobject["rm"] = "成功";
var results = new JObject;
var coupon_id = JObject.Parse(oSession.GetRequestBodyAsString())["coupon_id"].ToString();
coupon_id = coupon_id.Substring(coupon_id.Length - 3);
results.Add("coupon", gencoupon(coupon_id, 1));
oJobject.Add("results", results);
FiddlerApplication.Log.LogString('Coupon Detail Request');
}
if (oSession.uriContains("/redeem")){
oJobject["rc"] = 1;
oJobject["rm"] = "成功";
var results = new JObject;
var coupon_id = JObject.Parse(oSession.GetRequestBodyAsString())["coupon_id"].ToString();
var current_time = JObject.Parse(oSession.GetRequestBodyAsString())["source_info"]["device_time"].ToString()
coupon_id = coupon_id.Substring(coupon_id.Length - 3);
results.Add("coupon", gencoupon(coupon_id, 2));
oJobject.Add("results", results);
oJobject["results"]["coupon"].Add("redeem_datetime", current_time);
oJobject["results"].Add("current_datetime", current_time);
FiddlerApplication.Log.LogString('Coupon Redeem');
}
oSession.utilSetResponseBody(oJobject.ToString());
}
if (oSession.host == "v4.srv.seadog007.me"){
if (oSession.uriContains("/mcdapp/version")){
oSession.utilDecodeResponse();
if (System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes) == version){
FiddlerApplication.Log.LogString('Verification confirmed');
verified = 1;
var url = "http://v4.srv.seadog007.me/mcdapp/list.txt";
FiddlerObject.utilIssueRequest("GET " + url + " HTTP/1.0\r\nLoadList: 1\r\n\r\n");
FiddlerApplication.Log.LogString('Fetching Coupon List');
}else{
FiddlerApplication.Log.LogString(oSession.responseBodyBytes);
FiddlerApplication.Log.LogString("Verify Failed");
}
}
}
if (oSession.RequestHeaders["LoadList"] == 1){
oSession.utilDecodeResponse();
FiddlerApplication.Log.LogString("Prepare To Prase List");
coupon_list = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes).Remove(System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes).Length - 1, 1).Split("\n");
FiddlerApplication.Log.LogString("List: " + coupon_list);
FiddlerApplication.Log.LogString("List loaded");
}
}
static function gencoupon(id, status){
var coupon = new JObject;
coupon.Add("coupon_id", int("123456" + id.ToString()));
coupon.Add("type", "coupon");
coupon.Add("status", int(status));
var object_info = new JObject;
object_info.Add("object_id", 123);
var image = new JObject;
image.Add("url", "http://v4.srv.seadog007.me/mcdapp/P_G" + id.ToString() + ".jpg");
image.Add("width", 1080);
image.Add("height", 1920);
object_info.Add("image", image);
object_info.Add("title", "test");
object_info.Add("redeem_end_datetime", randomdate() + " 23:59:59");
coupon.Add("object_info", object_info);
return coupon;
}
static function randomdate(){
var someDate = new Date();
var numberOfDaysToAdd = RNG.Next(1,10);
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var yyyy = someDate.getFullYear();
return yyyy + "/"+ mm + "/" + dd;
}
static function Main() {
FiddlerApplication.Log.LogString("-----------------New Run-----------------");
var verified = 0;
var url = "http://v4.srv.seadog007.me/mcdapp/version";
FiddlerObject.utilIssueRequest("GET " + url + " HTTP/1.0\r\n\r\n");
FiddlerApplication.Log.LogString("Verifcating");
FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment