Skip to content

Instantly share code, notes, and snippets.

View webgtx's full-sized avatar
:accessibility:
Hope is not a strategy

Alex Zolotarov webgtx

:accessibility:
Hope is not a strategy
View GitHub Profile
@webgtx
webgtx / sample.ps1
Created June 17, 2023 04:15
Sample ICACLS commands to set owner, grant full control, read-only, and read plus execute access
::Set Owner of a specific file
ICACLS "D:\test\test.txt" /setowner "administrator"
::Grant Full Control
ICACLS "D:\test\test.txt" /grant:r "administrator:(F)" /C
::Grant Read and Execute Access of a specific file
ICACLS "D:\test\test.txt" /grant:r "users:(RX)" /C
::Grant Read-only Access of a specific file
@webgtx
webgtx / guesstheword.rb
Created June 16, 2023 04:37
Guess the word
require "base64"
secret_word = Base64.decode64("bGlnaHRzYWJlcg==")
player_word = "*" * secret_word.length
attempts = 11
puts """
Welcome to the game where you have to guess a word !
secret word has #{secret_word.length} letters, good luck.
@webgtx
webgtx / main.md
Created June 1, 2023 17:42
Upgrading shell to interactive remote shell

When connected with a reverse or bind shell you'll notice that no interactive commands will work and hitting Ctrl+c will terminate your session. To fix this, you'll need to attach it to a TTY (make it interactive). Here's how:

python3 -c 'import pty; pty.spawn("/bin/bash")'
@webgtx
webgtx / scheme_sqlite3.rb
Created May 26, 2023 17:21
sqilte3 scheme example in ruby
require "sqlite3"
db = SQLite3::Database.new("database.db")
db.execute(<<-SQL)
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
name TXT,
age INTEGER
);
SQL
@webgtx
webgtx / domain_extractor.rb
Created May 26, 2023 00:25
Regex in ruby, good example
def domain_name(url)
regex = /(http|https):\/\/(?:www\.)?(?<domain_name>.*?)\./
url.match(regex)[:domain_name]
end
@webgtx
webgtx / ansible.cfg
Last active May 16, 2023 21:57 — forked from wbcurry/.ansible.cfg
Config Boilerplate: ansible.cfg
# config file for ansible -- http://ansible.com/
# ==============================================
# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first
[defaults]
@webgtx
webgtx / main.md
Created April 10, 2023 04:13
How to reuse the same address in python sockets?
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # enable address reuse
server.bind((HOST, PORT))
server.listen(5)
print(f"RSHELL Server is running on {HOST}:{PORT}")

By calling setsockopt() on the socket object with the SO_REUSEADDR option, you are telling the operating system to allow the reuse of the same address. This should help you avoid the Address already in use error when restarting your server.

@webgtx
webgtx / main.md
Created March 29, 2023 20:11
Wordpress cheatsheat

All Content Editors

  1. Static Editor - for modules
  2. Elementor - For static texts and sections
@webgtx
webgtx / main.md
Created March 19, 2023 20:12
Authenticate to Google Container Registry with Podman

Authenticate to Google Container Registry with Podman

the xx.gcr.io is the host name. for example http://us.gcr.io etc use this doc

gcloud auth print-access-token | podman login -u oauth2accesstoken --password-stdin XX.gcr.io
@webgtx
webgtx / main.md
Last active February 25, 2023 11:49
is it ok to run podman in the toolbox?

By default, the toolbox command works in toolbox container and podman does not.

However, if you want to use podman from within a toolbox container, you can use flatpak-spawn --host to run a command from outside the toolbox from within the toolbox.

If you alias podman to flatpak-spawn --host podman inside your container, then it’ll run your system’s podman command from within the container.

This is mainly useful if you have a terminal set up to launch your dev environment as a toolbox container and you want to run a command outside of your container sometimes.

(For what it’s worth, some commands already seem to mostly “just work” inside a container, like toolbox and rpm-ostree.)