Skip to content

Instantly share code, notes, and snippets.

View betteray's full-sized avatar
🙃

Ray betteray

🙃
  • Beijing
View GitHub Profile
NSBundle *mainBundle = [NSBundle mainBundle];
[mainBundle aspect_hookSelector:@selector(bundleIdentifier)
withOptions:AspectPositionInstead
usingBlock:^(id<AspectInfo> info) {
NSString *originalID = @"com.netease.cloudmusic";
[[info originalInvocation] setReturnValue:&originalID];
} error:nil];
NSString *hookedID = [mainBundle bundleIdentifier];
NSLog(@"%@", hookedID);
#import <UIKit/UIKit.h>
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
NSLog(@"MTTime 启动");
%orig;
MSImageRef image = MSGetImageByName("/System/Library/PrivateFrameworks/CoreTime.framework/CoreTime");
breakpoint set -r '\[ClassName .*\]$'
#!/bin/sh
# Insert_CydiaSubstrate.sh
# UMAnalytics_Sdk_Demo
#
# Created by 罗红瑞 on 29/12/2017.
#
# ---------------------------------------------------
# 1. Dir Things
#import <Foundation/Foundation.h>
#import <CydiaSubstrate/CydiaSubstrate2.h>
#import <UIKit/UIKit.h>
DefineObjCHook(void, viewDidLoad, UIViewController* self, SEL _cmd) {
original_viewDidLoad(self, _cmd);
BOOL prefferdTimeLine = [[NSUserDefaults standardUserDefaults] boolForKey:@"preffered_timeline"];
if (prefferdTimeLine) {
adb shell lsof | grep <your-pid> | wc -l
adb shell ls -l /proc/<your-pid>/fd | wc -l
https://sdgsystems.com/blog/android-memory-and-file-descriptor-leaks-diagnosis-and-debugging-sdg-blog
File Descriptors
This is perhaps the sneakiest Android resource leak. Each app has a hard limit of 1024 file descriptors. Fortunately, 1024 file descriptors is an extremely generous limit, which should not be encountered during day-to-day development. Unfortunately, when coding errors introduce file descriptor leaks, the resultant crashes—Android immediately closes any app which exceeds its file descriptor allocation—do not put any useful debugging information in the logs. It is worth investigating any crash which shows those symptoms as a file descriptor leak.
@betteray
betteray / openssl-maker.sh
Last active August 7, 2018 12:15 — forked from letiemble/openssl-maker.sh
A bash script to generate "all-in-one" OpenSSL static libraries for OS X and iOS. The script produces fat static libraries (i386, x86_64 for OS X) and (i386, x86_64, armv7, armv7s, arm64 for iOS) suitable for integration in both OS X and iOS project.
#!/bin/bash
###############################################################################
## ##
## Build and package OpenSSL static libraries for OSX/iOS ##
## ##
## This script is in the public domain. ##
## Creator : Laurent Etiemble ##
## ##
###############################################################################
@betteray
betteray / UsbData.java
Created August 13, 2018 06:31 — forked from felHR85/UsbData.java
An easy to use android solution to get a readable representation of Usb vid (vendor name) and pid (product name). Data is collected and stored in a local SQLite database from http://www.linux-usb.org/usb-ids.html
public class UsbData
{
private String vendorId;
private String vendorName;
private String productId;
private String productName;
public UsbData(String vendorId, String vendorName, String productId, String productName)
{
@betteray
betteray / gist:628bd58712b9b07bc02b1582d0a2640e
Created August 29, 2018 06:25 — forked from lee-dohm/gist:3439284
Detect the debugger using Objective-C on iOS or OS X
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static bool AmIBeingDebugged(void)
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
{
This can be expanded to include CRC8, CRC16 , etc...
: (Objective-C)
#define DEFAULT_POLYNOMIAL 0xEDB88320L
#define DEFAULT_SEED 0xFFFFFFFFL
@interface NSData (CRC)
-(uint32_t) crc32;
-(uint32_t) crc32WithSeed:(uint32_t)seed;