Skip to content

Instantly share code, notes, and snippets.

@jonnystorm
jonnystorm / test_snmp.erl
Created February 9, 2020 23:58
SNMPv3 USM AuthPriv AES test for Erlang OTP
-module(test_snmp).
-export([main/0]).
main() ->
snmpm:start(),
EngineID = [128,0,0,0,6],
SecName = "v3_user",
AuthPass = "authpass",
AuthKey =
@jonnystorm
jonnystorm / gist:9c6cfe411fd5bf4e433fc01137c48412
Created August 10, 2018 15:40
hdparm: so danger, much exceptional
[10:29:32] jstorm[1]@alarbus:~$ (man hdparm; hdparm 2>&1) |
grep -i dangerous |
sed -E 's/(\w+ dangerous|dangerous)/\n\1\n/i' |
sed -e 's/^are //' |
grep -i dangerous |
sort |
uniq -c
14 DANGEROUS
2 EXCEPTIONALLY DANGEROUS
7 EXTREMELY DANGEROUS
@jonnystorm
jonnystorm / notes.sh
Last active May 13, 2017 16:22
Notes for setting up Arch Linux ARM on Asus C201P
# Logging in as a user in wheel gives
# 'Failed to set ACL on /var/log/journal/...: Operation not supported'.
#
# `getfactl` shows incorrect permissions for `/var/log/journal`.
#
# Setting permissions manually with `setfacl` returns 'Operation not supported'.
#
# `tune2fs -l /dev/mmcblk1p2` shows 'user_xattr acl'.
#
# `# CONFIG_EXT4_FS_POSIX_ACL is not set` found in
@jonnystorm
jonnystorm / gist:191e6fda421a80fbafaf6f1b8c3291f2
Created April 22, 2017 20:46
Digest failure maybe caused by unset engine boots, time
# From the server:
#
# Incoming SNMP packet
# *Mar 1 01:23:00.327: v3 packet security model: v3 security level: noauth
# *Mar 1 01:23:00.331: username: admin
# *Mar 1 01:23:00.331: snmpEngineID: 800000090300C2014D0C0000
# *Mar 1 01:23:00.331: snmpEngineBoots: 0 snmpEngineTime: 0
15:43:56.287684 12:a7:33:b9:da:d6 > c2:01:4d:0c:00:00, ethertype IPv4 (0x0800), length 160: (tos 0x0, ttl 64, id 16713, offset 0, flags [DF], proto UDP (17), length 146)
192.0.2.2.5000 > 192.0.2.3.161: [udp sum ok] { SNMPv3 { F=ar } { USM B=0 T=0 U="admin" } { ScopedPDU E=_80_00_00_09_03_00_c2_01_4d_0c_00_00 C="" { GetRequest(28) R=1582425448 .1.3.6.1.2.1.1.5.0 } } }
@jonnystorm
jonnystorm / test.ex
Created April 22, 2017 19:30
Test of snmp-elixir noAuthNoPriv
iex(1)> SNMP.start
dets: file "/home/jstorm/dev/working/elixir/snmp-elixir/snmpm_config_db" not properly closed, repairing ...
:ok
iex(2)> cred = SNMP.credential [:v3, :no_auth_no_priv, "admin"]
%SNMP.USMNoAuthNoPrivCredential{sec_level: :noAuthNoPriv, sec_model: :usm,
sec_name: 'admin', version: :v3}
iex(3)> SNMP.get [1,3,6,1,2,1,1,5,0], "192.0.2.3", cred, engine_id: <<0x800000090300c2014d0c0000::12*8>>
@jonnystorm
jonnystorm / gist:eaa560ff971b6b124eb611c8faf584ba
Last active April 2, 2017 16:42
Assortment of errors from compiling net-snmp MIBs w/ OTP
IPV6-TC.mib: 5: TEXTUAL-CONVENTION is only allowed in SNMPv2.
IPV6-TC.mib: 8: syntax error before: 'TEXTUAL-CONVENTION'
UCD-SNMP-MIB.mib: 785: Number of columns differs from SEQUENCE definition (object:dskTotalLow).
UCD-SNMP-MIB.mib: 794: Number of columns differs from SEQUENCE definition (object:dskTotalHigh).
UCD-SNMP-MIB.mib: 803: Number of columns differs from SEQUENCE definition (object:dskAvailLow).
UCD-SNMP-MIB.mib: 812: Number of columns differs from SEQUENCE definition (object:dskAvailHigh).
UCD-SNMP-MIB.mib: 821: Number of columns differs from SEQUENCE definition (object:dskUsedLow).
UCD-SNMP-MIB.mib: 830: Number of columns differs from SEQUENCE definition (object:dskUsedHigh).
UCD-SNMP-MIB.mib: 857: Number of columns differs from SEQUENCE definition (object:laTable).
UCD-SNMP-MIB.mib: 865: Number of columns differs from SEQUENCE definition (object:laEntry).
%%% This file was automatically generated by snmpc_mib_to_hrl version 5.2.4
%%% Date: 08-Mar-2017::07:42:27
-ifndef('IP-FORWARD-MIB').
-define('IP-FORWARD-MIB', true).
%% Oids
-define(ipForward, [1,3,6,1,2,1,4,24]).
-define(ipCidrRouteNumber, [1,3,6,1,2,1,4,24,3]).
-define(ipCidrRouteNumber_instance, [1,3,6,1,2,1,4,24,3,0]).
@jonnystorm
jonnystorm / gist:aa39a241a375975ce78b2a390fdf991f
Created March 24, 2017 20:24
USM engineId discovery - false starts
iex> SNMP.start
{:ok, #PID<0.175.0>}
iex> cred = SNMP.credential [:v3, :no_auth_no_priv, "admin"]
[version: :v3, sec_model: :usm, sec_level: :noAuthNoPriv, sec_name: 'admin']
iex> SNMP.get([1,3,6,1,2,1,1,5,0], URI.parse("snmp://192.0.2.3"), cred)
14:30:12.544 [debug] Will register agent snmp://192.0.2.3 with target [130, 219, 114, 183, 132, 30, 20, 148, 117, 155, 154, 175, 231, 194, 102, 115, 99, 57, 90, 71] and config [engine_id: [128, 0, 0, 0, 6], address: [192, 0, 2, 3], port: 161, tdomain: :transportDomainUdpIpv4, version: :v3, sec_model: :usm, sec_level: :noAuthNoPriv, sec_name: 'admin'].
@jonnystorm
jonnystorm / gist:7136bff23cca0f84219d6cd4cdaeabfc
Last active March 28, 2017 15:10
Resolve MIB name to OID in Elixir
# Change MIB extensions from .txt to .mib
copy -r /usr/share/snmp/mibs /home/jstorm/mibs
cd /home/jstorm/mibs
rename '\.txt$' .mib *
# Replace instances of RowStatus with INTEGER in MIBs.
# Otherwise, expect compilation errors.
# Compile dependencies before target MIB (IP-FORWARD-MIB, in this case).
iex> :snmpc.compile('IANAifType-MIB', [i: ['/home/jstorm/mibs']])
! Much of ASA syntax is ambiguous, over-determined, or just plain confused.
! Below is one such example.
!
! Name two interfaces using the real/mapped interface delimiter, ','.
! In general, ASA accepts a shocking variety of characters for names.
! Keywords are unreserved.
! Only naming conflicts occur with built-in objects.
!
ASA(config)# int po1.22
ASA(config-subif)# vlan 22