mindnotes

fast notes about tech stuff

sha512 shadow passwords

mkpasswd

$ apt install whois -y
$ mkpasswd --method=sha-512

using openssl

passing password

$ openssl passwd -6 '<password>'

passing both password and salt

$ openssl passwd -6 --salt '<salt>' '<password>'

passing via stdin

$ openssl passwd -6 -stdin

using python

$ python -c 'import crypt; print(crypt.crypt("<password>", crypt.mksalt(crypt.METHOD_SHA512)))'

using ruby

$ ruby -e 'require "securerandom"; puts SecureRandom.alphanumeric(20).crypt("$6$" + rand(36 ** 8).to_s(36))'

normal random passwords

using openssl with hex

$ openssl rand -hex 15

using openssl with base64

$ openssl rand -base64 15

using urandom

$ cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9-_\$' | fold -w 25 | sed 1q

bcrypt

using httpd

$ htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/'

Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

A simple script that you can schedule in your cron.

#!/bin/bash

INSTANCE_URL="https://bolha.us"
TOKEN="YOUR_TOKEN_HERE"
TOOT="YOUR_MESSAGE_HERE"

curl ${INSTANCE_URL}/api/v1/statuses -H "Authorization: Bearer $TOKEN" -F "status=${TOOT}"

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

How to get the list of all blocked instances in your instance using CURL and the Mastodon API?

It's simple!

$ curl -s https://bolha.us/api/v1/instance/domain_blocks|jq

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

Essa é a forma de importar um certificado P12 pelo terminal. Isso é muito útil, especialmente quando você não tem acesso ao KeyChain Access no MacOs.

command

$ security import ./JOSE_AUGUSTO_DA_COSTA_CARVALHO.p12 -P 123456
1 identity imported

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

This is what you need to do to import a P12 certificate using the terminal. It's helpful if you need permission to open the Keychain Access app.

command

$ security import ./JOSE_AUGUSTO_DA_COSTA_CARVALHO.p12 -P 123456
1 identity imported

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

Remember to run these commands daily for those installing Mastodon instances to keep your server running smoothly.

Runing in a non-docker installation

$ tootctl search deploy
$ tootctl media remove --days=30
$ tootctl preview_cards remove --days=30

Running in a docker-compose installation

docker-compose -f /opt/mastodon-docker/docker-compose.yml run --rm shell tootctl search deploy

docker-compose -f /opt/mastodon-docker/docker-compose.yml run --rm shell tootctl media remove --days=30

docker-compose -f /opt/mastodon-docker/docker-compose.yml run --rm shell tootctl preview_cards remove --days=30

In our example, the mastodon docker config resides on the directory /opt/mastodon-docker.

Understanding each task

The first command (search deploy) will read the data inside your elastic search, create indexes for toots, tags, and links, and populate the explore page.

The last two commands will remove content from external instances cached in your disk. They will remove images, audio, video, avatars, user image headers (media remove) and preview cards thumbnails (preview_cards remove).

Creating cronjobs

# Daily 2 AM

00 2 * * * /opt/mastodon-scripts/clear_attachments.sh

# Daily 2:30 AM

30 2 * * * /opt/mastodon-scripts/clear_preview_cards.sh

# Daily 3:00 AM

00 3 * * * /opt/mastodon-scripts/generate_search_index.sh

In our example, the scripts reside in the directory /opt/mastodon-scripts.

Refs


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

Pegar parâmetro usando $1 $2 e $3 é fácil né?

Todo mundo já sabe!

E se você quiser pegar apenas os parâmetros do 3 pra frente?

${*:3}

Loko.

:)

refs

3.4.2 Special Parameters
The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed.

*
($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional parameter expands to a separate word. In contexts where it is performed, those words are subject to further word splitting and filename expansion. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. That is, "$*" is equivalent to "$1c$2c…", where c is the first character of the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined without intervening separators.

:* (!)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

This tip is for Mastodon admins only.

If you have internal accounts like this...

@help@bolha.us @notices@bolha.us @tips@bolha.us @status@bolha.us @backup@bolha.us

...and want to define that every one of your instance needs to follow them, you can do this:

$ docker-compose -f /opt/mastodon-docker/docker-compose.yml run --rm shell tootctl accounts follow status

And to be sure that everyone is following, you can create a cronjob to enforce this every day.

35 4 * * * /opt/mastodon-scripts/follow.sh

Please only do this with service accounts.

Be sure to inform this inside your about/rules page.

Use with moderation and always respect the privacy of your community.

refs

Mastodon with docker?

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

Usamos o getopts para criar opções para nossos scripts, algo como

$ comando -e production -h localhost -t compress

Esse foi só um exemplo de comando são comandos com parâmetros e valores.

Exemplo

Veja aqui um exemplo de uso do getops

while getopts ":e:h" flag;do
    case "${flag}" in
        e) 
          executa_comando_com_parametro ${OPTARG}
        ;;
        h|help)
          comando_mostra_ajuda
        ;;
        :)
          echo -e "\nFaltou valor para esse parâmetro.\n"
          exit 1
        ;;
        *)
         echo -e "\nParâmetro desconhecido!\n"
          echo -e "Tá precisando de uma mão?\n"
          echo -e "Digita aí"
          echo -e "$ comando -h"
          exit 1
        ;;
    esac
done

refs


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]

Trocar um valor de uma chave/valor ou configuração/valor em um arquivos qualquer

valor fora do início de linha

sed -i '' '/AUTH0_CLIENT_ID\: .*/"ToKeNToKeNToKeNToKeN"/' file.conf

valor em início de linha

sed "/^api_url=/s/=.*/=api.bolha.us/" daemon.conf

Testado no sed do Mac OS.

:)


Did you like our content?

We have a lot to share; visit our site!

Our fediverse services ;)

Chat and video? We have it!

And utilities for our community

You can also visit our hacking space!

Follow our founder!

Follow the status of our tools

Do you want to support us? You can!

See you!

[s]