Skip to content

Instantly share code, notes, and snippets.

@47star
47star / google-user-content-ip-list.py
Created August 15, 2023 09:48
Fetch IPv4 blocks of googleusercontent.com
import re
from scapy.all import *
from scapy.layers.dns import DNS, DNSQR
from scapy.layers.inet import IP, UDP
def query(n, t="TXT"):
return sr1(
IP(dst="8.8.8.8") / UDP(dport=53) / DNS(rd=1, qd=DNSQR(qname=n, qtype=t)),
verbose=False,
)[DNS]
@47star
47star / AttributeContainer.kt
Created May 15, 2023 04:20
Attribute Container for Kotlin Coroutines
import kotlinx.coroutines.currentCoroutineContext
import kotlin.coroutines.CoroutineContext
interface AttributeContainer : CoroutineContext.Element {
@InternalApi
data class Key(val fqName: String) : CoroutineContext.Key<AttributeContainer>
@InternalApi
override val key: CoroutineContext.Key<*> get() = Key(fqName)
@47star
47star / settings.gradle.kts
Created April 11, 2023 04:51
Snippet for Gradle submodule definition in Kotlin DSL
class GradleSubmodule(
private val name: String,
private vararg val children: GradleSubmodule,
) {
operator fun unaryPlus() = load("")
private fun load(parent: String) {
include("$parent:$name")
for (child in children) {
@47star
47star / settings.gradle.kts
Created September 19, 2022 11:43
Gradle Submodule Notation for Kotlin DSL
class GradleSubmodule(
private val name: String,
private vararg val children: GradleSubmodule,
) {
operator fun unaryPlus() = load("")
private fun load(parent: String) {
include("$parent:$name")
for (child in children) {
@47star
47star / cloudflare.rsc
Created May 6, 2021 09:46
Cloudflare IP ranges registration script for MikroTik RouterOS
/ip firewall address-list
add address=173.245.48.0/20 list=Cloudflare
add address=103.21.244.0/22 list=Cloudflare
add address=103.22.200.0/22 list=Cloudflare
add address=103.31.4.0/22 list=Cloudflare
add address=141.101.64.0/18 list=Cloudflare
add address=108.162.192.0/18 list=Cloudflare
add address=190.93.240.0/20 list=Cloudflare
add address=188.114.96.0/20 list=Cloudflare
add address=197.234.240.0/22 list=Cloudflare
@47star
47star / docker-installation-ubuntu.sh
Last active September 10, 2021 10:06
Docker installation script for Ubuntu
#!/bin/bash
sudo apt-get update -y
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
@47star
47star / Set-NetworkAdapterName.ps1
Created April 5, 2019 15:44
Set network adapter name for Windows Server.
$hardwareid = ((gwmi Win32_PnPSignedDriver -Filter "Description = 'Microsoft Hyper-V Network Adapter'").HardwareID[0]).ToUpper();
foreach ($drivername in (gwmi Win32_PnPSignedDriver -Filter "Description = 'Microsoft Hyper-V Network Adapter'").DeviceID) {
$driverid = $drivername.Replace($hardwareid, "").Replace("\", "").ToLower();
$registryPath = "HKLM:\SYSTEM\ControlSet001\Enum\VMBUS\" + $hardwareid.Replace("VMBUS\", "").ToLower() + "\" + $driverid;
Set-ItemProperty -Path $registryPath -Name "FriendlyName" -Value "NIC Name Goes Here"
}
@47star
47star / Set-VMIPAddress.ps1
Created April 5, 2019 15:23
Assign static IP address for Hyper-V Guest.
param( [String]$VMName="",
[String]$Address="",
[String]$Gateway="",
[String]$SubnetMask="",
[String]$DNS1="",
[String]$DNS2="")
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_VirtualSystemManagementService
$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$VMName'"
$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", "Msvm_SettingsDefineState", $null, $null, "SettingData", "ManagedElement", $false, $null) | % {$_})
$Msvm_SyntheticEthernetPortSettingData = $Msvm_VirtualSystemSettingData.GetRelated("Msvm_SyntheticEthernetPortSettingData")
@47star
47star / Install-GroupPolicy.ps1
Created March 30, 2019 14:15
Install Group Policy Editor in Windows 10 Home.
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$features = Get-ChildItem $env:systemroot"\servicing\Packages\" -Filter "Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum"
$features += Get-ChildItem $env:systemroot"\servicing\Packages\" -Filter "Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum"
Foreach($feature in $features) {
dism /online /norestart /add-package:$env:systemroot"\servicing\Packages\"$feature
}
echo ""
echo ""
echo ""
echo "잠시 기다려 주십시오."