Pular para o conteúdo principal

Extracting package from Android via adb

· Leitura de um minuto

First of all, list packages

adb shell pm list packages |grep appname

Then find out where it is placed the required apk

adb shell pm path the.package.name

Finally pull the desired apk

adb pull /data/app/path-to-apk/apk-name.apk ~/tmp/

Pushing custom images to your private docker registry

· Leitura de um minuto

Creating the registry

docker-machine create registry
docker-machine ssh registry
docker run -d -p 5000:5000 --restart=always --name registry registry:2

Enabling push to "insecure" docker registry

sudo vim /etc/docker/daemon.json

Restarting docker

sudo systemctl restart docker.service

Assuming you docker-machine IP is 192.168.99.100, insert this line:

{ "insecure-registries":["192.168.99.100:5000"] }

Building an image with tag

docker build --tag my-image -f src/main/docker/Dockerfile .

Tagging your custom image to point to your local registry:

 docker tag my-image 192.168.99.100:5000/my-image

Pushing your custom image:

 docker push 192.168.99.100:5000/my-image

Reference: Deploying a registry server

Logging into keycloak using auth URL

· Leitura de um minuto
URL: http://{keycloak_url}/auth/realms/{realm}/protocol/openid-connect/token
Request Headers:

grant_type:password client_id:{client_id} response_type:token username:{username} password:{password} client_secret: {client_secret} -> Just needed when Access type = confidential

Retrieving logged user info from Keycloak

· Leitura de um minuto

Just do a GET to the keycloak URL:

 

http://{SERVER_URL}/auth/realms/{realm}/protocol/openid-connect/userinfo

 

Dont forget to send this request with you authorization header. Ex:

Authorization: Bearer {token}
~~~

Calculating Heap Size - Xms and Xmx

· Leitura de um minuto

Xmx

Formula: 1.43x Maximum heap size used by your application. Example: If your application allocated 4000Mb(max) of heap. So

1.43 x 4000 = 5720

So your Xmx flag should be: -Xmx=5720

Xms

Formula: 0.40x Maximum head available(Xmx) Example: if your Xmx=5720,

0.40 x 5720 = 2288

So your Xms flag should be: -Xms=2288

Configuring Postfix relay on Fedora/CentOS

· Leitura de um minuto

Installing libs

yum install postfix mailx cyrus-sasl-plain

Writing smtp authentication config

echo "smtp_user@gmail.com smtp_user:smtp_passwd" > /etc/postfix/sasl_passwd
postmap hash:/etc/postfix/sasl_passwd

Edit mail.cnf file like following

#debug_peer_list=smtp.gmail.com
#debug_peer_level=3

compatibility_level = 2

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix
mail_owner = postfix

myhostname = hostname.example.com
mydomain = example.com

inet_interfaces = all
inet_protocols = ipv4

unknown_local_recipient_reject_code = 550

mailq_path = /usr/bin/mailq.postfix

setgid_group = postdrop

html_directory = no

manpage_directory = /usr/share/man

relayhost = smtp.gmail.com
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
mynetworks = 14.11.0.0/16
transport_maps = hash:/etc/postfix/transport


Edit /etc/postfix/relayhost_map file like following:

usu01@gmail.com usu01@gmail.com:senha
usu02@gmail.com usu02@gmail.com:senha

Type this command and hit enter

postmap /etc/postfix/relayhost_map

** Include theses lines in /etc/aliases file:**

usu01: usu01@gmail.com
usu02: usu02@gmail.com

Type this command and hit enter

postmap /etc/aliases

Edit /etc/postfix/transport file:

* smtp:smtp.gmail.com

Type these command and hit enter

postmap /etc/postfix/transport
service postfix restart

Enabling SSH access with SSH KEYS

· Leitura de um minuto

Info

This approach is useful when you don't want to send your login/passwd everytime you need to acess a remote host.

On the client host

Type:

    ssh-keygen -t rsa -f [KEY_PATH]/id_rsa

Send key to your server

    cd
ssh-copy-id user@123.45.56.78