Skip to content

Instantly share code, notes, and snippets.

📞
Working on KnocKnock

Jack Zhang jackz314

📞
Working on KnocKnock
Block or report user

Report or block jackz314

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jackz314
jackz314 / multi_prime_rsa.py
Created Oct 2, 2019
Multi Prime RSA solver
View multi_prime_rsa.py
# Solves multi prime rsa given n, e, and c. Need to factor n into primes first (recommend yafu)
# Reference https://crypto.stackexchange.com/questions/31109/rsa-enc-decryption-with-multiple-prime-modulus-using-crt
# From https://github.com/diogoaj/ctf-writeups/tree/master/2018/Timisoara/crypto/NotYourAverageRSA
# Params
e = 65537
c = 48761539940486768790697951968441053167086423529120379009399989923982917278530780108524481919294548305561552133247376067350664771674488982501980538923179804440135482761541868213581098181220801732284669971107195377327445661261746882474615837238429855596647745621191046720648860759474615170945636435027382702345930153884587334870109990234396501579
n = 81736943705459767985288486167314099164146317197040392194768161097750074479540025761100109449092862009195976097250151609584294118669228141027624354052423638509988705830737675936098155468596924772948252465412194715615408850250410310761063399013426728554729053139453019049285162533445627620506060381552244023004446417793032764776342793336374
@jackz314
jackz314 / SetEditTextCursorColor.java
Created Sep 29, 2018
A reflection method used to set EditText Cursor Color with support for Android P (API 28)
View SetEditTextCursorColor.java
public static void setEditTextCursorColor(EditText editText, int color) {
try {
// Get the cursor resource id
if(Build.VERSION.SDK_INT >= 28){//set differently in Android P and above (API 28+)
Field field = TextView.class.getDeclaredField("mCursorDrawableRes");
field.setAccessible(true);
int drawableResId = field.getInt(editText);
// Get the editor
field = TextView.class.getDeclaredField("mEditor");
@jackz314
jackz314 / disable.bat
Created Jul 12, 2019
Turn off Hyper-V on Windows completely (for VT-X to work)
View disable.bat
[in Windows UI]
Turn on/off Windows Features -> Untick Hyper-V
[in cmd or PowerShell]
bcdedit /set hypervisorlaunchtype off
[in PowerShell]
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
@jackz314
jackz314 / occur.sh
Created Jun 29, 2019
Sort occurrence of words among a directory of files
View occur.sh
cat *.txt | tr '[:space:]' '[\n*]' | grep -v "^\s*$" | sort | uniq -c | sort -bnr | head -n 100
#extension .txt, limit result to top 100. Change if needed
@jackz314
jackz314 / DragEditText.java
Created Apr 20, 2019
Drag to select text with a mouse inside Android EditText like on computers
View DragEditText.java
EditText mText = ....
final int[] beginOffset = {-1};
View.OnTouchListener otl = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE){//only change behavior for mouse
int i = event.getAction();
if (i == MotionEvent.ACTION_DOWN) {
Layout layout = ((EditText) v).getLayout();
float x = event.getX() + mText.getScrollX();
@jackz314
jackz314 / openPreference.java
Last active Sep 29, 2018
Open a Preference in Android Setting (preference) Activity
View openPreference.java
private void openPreference(String key) {
PreferenceScreen preferenceScreen = getPreferenceScreen();
final ListAdapter listAdapter = preferenceScreen.getRootAdapter();
final int itemsCount = listAdapter.getCount();
int itemNumber;
for (itemNumber = 0; itemNumber < itemsCount; ++itemNumber) {
if (listAdapter.getItem(itemNumber).equals(findPreference(key))) {
preferenceScreen.onItemClick(null, null, itemNumber, 0);
break;
@jackz314
jackz314 / DetectPastTime.java
Last active Sep 29, 2018
Detect Past Times In a String
View DetectPastTime.java
String[] pastTimeIndicators = new String[]{"last sec", "last min", "last hr", "last hour", "yesterday", "last week", "last month", "last year"};
if(isStringContainAnyOfTheseWords(group.getText().toLowerCase(), pastTimeIndicators)){
Toast.makeText(getContext(),getString(R.string.past_time_warning),Toast.LENGTH_LONG).show();
Calendar opCalendar = Calendar.getInstance();
opCalendar.setTime(currentTime);
opCalendar.add(Calendar.SECOND,-1);
long lastSecTime = opCalendar.getTimeInMillis();
opCalendar.setTime(currentTime);
opCalendar.add(Calendar.MINUTE,-1);
long lastMinTime = opCalendar.getTimeI
You can’t perform that action at this time.