Skip to content

Instantly share code, notes, and snippets.

View adiroiban's full-sized avatar
🇺🇦
Slava Ukraini!

Adi Roiban adiroiban

🇺🇦
Slava Ukraini!
  • VGR, La Gomera
  • 21:38 (UTC +01:00)
View GitHub Profile
@adiroiban
adiroiban / gist:288b7f55553cd43bf02050d911b20575
Created April 20, 2021 12:31
pypy-3.7-alldeps-nocov-posix twisted failure on 2eeaacb
https://github.com/twisted/twisted/runs/2372418216#step:9:18222
FAIL]
Traceback (most recent call last):
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/words/test/test_irc.py", line 940, in test_ERRMSG
self.assertEqualBufferValue(reply, errReply)
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/words/test/test_irc.py", line 38, in assertEqualBufferValue
self.assertEqual(bufferValue, val)
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/trial/_synctest.py", line 424, in assertEqual
@adiroiban
adiroiban / aysnc_fs.py
Created March 12, 2021 14:17
Raw export of async FS API
class IResourceRunnable(IRunnable):
"""
A resource which acts as a client to provide the end-user functionality.
"""
avatar = Attribute('The client/credentials for this resource.')
def heartbeat():
"""
Called to signal that a command was requested for the location.
@adiroiban
adiroiban / pyradius_timeout.py
Created February 25, 2021 14:37
pyradius - no timeout error for invalid shared secret
class ChevahRadius(radius.Radius):
"""
Patched version while the upstream project is re-enabled.
"""
def send_message(self, message):
"""
Raise VerificationError if we got a response but couldn't be validated,
instead of raising the same error as timeout.
"""
@adiroiban
adiroiban / putty_ppk_read.py
Created December 16, 2020 16:38
Read putty private key in Python
# Code extracted from my private project, but released here as public code.
@classmethod
def _fromString_PRIVATE_PUTTY(cls, data, passphrase):
"""
Read a private Putty key.
Format is:
PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc | none
Comment: SINGLE_LINE_COMMENT
@adiroiban
adiroiban / twisted_proto_helpers_fork.py
Created December 11, 2020 16:41
Some twisted proto helpers
# Copyright (c) 2012 Adi Roiban.
# See LICENSE for details.
"""
Protocol to help with tests.
This comes in addition to standard twisted.test.proto_helpers
"""
from io import BytesIO
from StringIO import StringIO
@adiroiban
adiroiban / twisted_fail_http_proxy_request.py
Created December 5, 2020 13:51
Example of failing an HTTP proxy request in Twisted.
"""
In one terminal
$ $ python3 twisted_fail_http_proxy_request.py
In another terminal test it with:
$ curl -v -x http://localhost:8000 http://httpforever.com/
"""
@adiroiban
adiroiban / result.html
Created October 23, 2020 21:28
pydoctor private deprecations
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html>
<head>
<title>_trial_temp.test : API documentation</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="apidocs.css" />
@adiroiban
adiroiban / ldaptor-client-query.py
Created October 4, 2020 11:49
Simple ldaptor example to connect to a LDAP server, bind and dump the result.
"""
Run a simple LDAP client query.
Usage:
client-query [options]
-h --help Show this help.
Connection options:
--host=127.0.0.1 Connect to a specific host. [default: 127.0.0.1]
@adiroiban
adiroiban / aescrypt_sans_io.py
Created March 2, 2020 02:06
AES Crypt Sans I/O
"""
Implementation of AES Crypt witout any I/O operations.
"""
_AES_BLOCK_SIZE = 16
_AES_BUFFER_SIZE = 16 * 1024
_IV_SIZE = 16
_KEY_SIZE = 32
@adiroiban
adiroiban / powershell.sh
Created December 2, 2019 10:53
Change RDP port - Azure script
param($RDPPort=3389)
$TSPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server'
$RDPTCPpath = $TSPath + '\Winstations\RDP-Tcp'
Set-ItemProperty -Path $TSPath -name 'fDenyTSConnections' -Value 0
# RDP port
$portNumber = (Get-ItemProperty -Path $RDPTCPpath -Name 'PortNumber').PortNumber
Write-Host Get RDP PortNumber: $portNumber
if (!($portNumber -eq $RDPPort))