Vibe Coding – sudo read this

So, I am pretty lazy when it comes to typing out long commands and constantly typing in my password on my Mac.  I worked with my coding coach (ChatGPT – and by coach I mean I just have it spit out the code).  I had it write this, if you are using iTerm2, and you should, it will give you a TouchID prompt IF you have a device with a TouchID sensor connected, or are using your MacBook keyboard itself with TouchID, otherwise it will just give a password prompt, like an animal.  It backs up all the files it touches, because I don’t trust ChatGPT that much.  If it borks you, I’m sorry, so make a backup of your machine first and I’ll buy you an adult beverage when next we see each other.

To create the we are going to: nano install_touchid_sudo.sh and then add:

#!/bin/zsh
# Install Touch ID for sudo in iTerm2 only when a Touch ID Magic Keyboard is connected.
# Backs up every file it touches with .bak.<timestamp> and records a manifest for clean backout.

set -euo pipefail

TS="$(date +%Y%m%d-%H%M%S)"
INSTALL_DIR="$HOME/.local/share/touchid-sudo-iterm2"
MANIFEST="$INSTALL_DIR/manifest.$TS"
PAM_SUDO="/etc/pam.d/sudo"
BIN_DIR="$HOME/bin"
SUDO_WRAPPER="$BIN_DIR/sudo"
ZSHRC="$HOME/.zshrc"

mkdir -p "$INSTALL_DIR"
: > "$MANIFEST"

note() { printf '%s\n' "$*"; }
record() { printf '%s\t%s\n' "$1" "$2" >> "$MANIFEST"; }  # type<TAB>path

# 1) Backup and ensure pam_tid.so is present in /etc/pam.d/sudo
note "Backing up and enabling Touch ID in $PAM_SUDO..."
sudo cp "$PAM_SUDO" "${PAM_SUDO}.bak.${TS}"
record "backup" "${PAM_SUDO}.bak.${TS}"

if ! grep -q 'pam_tid\.so' "$PAM_SUDO"; then
  tmp="$(mktemp)"
  # Insert pam_tid.so as the first non-comment line
  awk 'BEGIN{ins=0}
       /^#/ && ins==0{print; next}
       ins==0{print "auth       sufficient     pam_tid.so"; ins=1}
       {print}
       END{if(ins==0) print "auth       sufficient     pam_tid.so"}' \
       "$PAM_SUDO" > "$tmp"
  sudo cp "$tmp" "$PAM_SUDO"
  rm -f "$tmp"
  record "modified" "$PAM_SUDO"
else
  note "pam_tid.so already present; leaving $PAM_SUDO content unchanged (backup still created)."
fi

# 2) Create ~/bin and install sudo wrapper (backup any existing one)
note "Installing conditional sudo wrapper at $SUDO_WRAPPER..."
mkdir -p "$BIN_DIR"

if [[ -f "$SUDO_WRAPPER" ]]; then
  cp "$SUDO_WRAPPER" "${SUDO_WRAPPER}.bak.${TS}"
  record "backup" "${SUDO_WRAPPER}.bak.${TS}"
fi

cat > "$SUDO_WRAPPER" <<'ZWRAP'
#!/bin/zsh
# iTerm2-scoped sudo wrapper that prefers Touch ID only when a Touch ID Magic Keyboard is connected.

set -euo pipefail

is_iterm2() {
  [[ "${TERM_PROGRAM:-}" == "iTerm.app" ]]
}

has_touchid_keyboard() {
  # Bluetooth: look for Magic Keyboard with Touch ID entries that are connected
  if system_profiler SPBluetoothDataType 2>/dev/null | \
       awk 'BEGIN{IGNORECASE=1}
            /Magic Keyboard with Touch ID( and Numeric Keypad)?/ {seen=1}
            /Connected: Yes/ && seen {connected=1}
            /^$/{ if(connected){print "YES"; exit} seen=connected=0 }' | grep -q YES; then
    return 0
  fi
  # USB: wired usage
  if system_profiler SPUSBDataType 2>/dev/null | \
       grep -Ei 'Magic Keyboard with Touch ID( and Numeric Keypad)?' >/dev/null; then
    return 0
  fi
  return 1
}

if is_iterm2 && has_touchid_keyboard; then
  exec /usr/bin/sudo "$@"
else
  exec /usr/bin/sudo "$@"
fi
ZWRAP

chmod +x "$SUDO_WRAPPER"
record "created" "$SUDO_WRAPPER"

# 3) Ensure ~/bin is in PATH via ~/.zshrc (backup before edit)
ensure_path_line='export PATH="$HOME/bin:$PATH"'
if ! print -r -- "$PATH" | tr ':' '\n' | grep -qx "$HOME/bin"; then
  note "Ensuring $HOME/bin precedes PATH in $ZSHRC..."
  if [[ -f "$ZSHRC" ]]; then
    cp "$ZSHRC" "${ZSHRC}.bak.${TS}"
    record "backup" "${ZSHRC}.bak.${TS}"
  else
    # Touch to create, then back it up empty for symmetry
    : > "$ZSHRC"
    cp "$ZSHRC" "${ZSHRC}.bak.${TS}"
    record "backup" "${ZSHRC}.bak.${TS}"
  fi
  # Only append if not already present
  if ! grep -Fxq "$ensure_path_line" "$ZSHRC"; then
    printf '\n%s\n' "$ensure_path_line" >> "$ZSHRC"
    record "modified" "$ZSHRC"
  fi
else
  note "~/bin already on PATH in current shell; no edit to $ZSHRC."
fi

# 4) Save a copy of the wrapper and metadata for reference
cp "$SUDO_WRAPPER" "$INSTALL_DIR/sudo.wrapper.$TS"
record "created" "$INSTALL_DIR/sudo.wrapper.$TS"
note "Install complete.
Manifest: $MANIFEST

Open a new iTerm2 session or 'source ~/.zshrc' to pick up PATH changes.
Behavior:
- In iTerm2 with a Touch ID Magic Keyboard connected: sudo will allow Touch ID.
- Otherwise: sudo falls back to password."

Now hit control-x to exit and y to save

 The rollback!

Create the file:

nano uninstall_touchid_sudo.sh

and add this:

#!/bin/zsh
# Back out the most recent install by restoring backups from the newest manifest.
# You can pass a specific manifest path as $1 to target that install.

set -euo pipefail

INSTALL_DIR="$HOME/.local/share/touchid-sudo-iterm2"
MANIFEST="${1:-}"

if [[ -z "$MANIFEST" ]]; then
  MANIFEST="$(ls -1t "$INSTALL_DIR"/manifest.* 2>/dev/null | head -n1 || true)"
fi

if [[ -z "$MANIFEST" || ! -f "$MANIFEST" ]]; then
  printf 'No manifest found. Nothing to do.\n' >&2
  exit 1
fi

printf 'Using manifest: %s\n' "$MANIFEST"

restore_file() {
  local backup="$1"
  # Original path is the backup path without the trailing ".bak.<timestamp>"
  local orig="${backup%\.bak.*}"
  if [[ -f "$backup" ]]; then
    # If restoring /etc/pam.d/*, use sudo
    if [[ "$orig" == /etc/pam.d/* ]]; then
      sudo cp "$backup" "$orig"
      printf 'Restored (sudo): %s -> %s\n' "$backup" "$orig"
    else
      cp "$backup" "$orig"
      printf 'Restored: %s -> %s\n' "$backup" "$orig"
    fi
  else
    printf 'Backup missing, skipping: %s\n' "$backup" >&2
  fi
}

# Read manifest lines: "<type>\t<path>"
# We restore backups and then optionally remove created files saved under INSTALL_DIR.
while IFS=$'\t' read -r typ path; do
  case "$typ" in
    backup)
      restore_file "$path"
      ;;
    created)
      # Only delete created artifacts under our install dir; leave ~/bin/sudo in place
      # unless there is also a backup we restored above.
      if [[ "$path" == "$INSTALL_DIR/"* ]]; then
        rm -f "$path" && printf 'Removed created artifact: %s\n' "$path"
      fi
      ;;
    modified)
      # Nothing to do here; restoring from backups handles this.
      :
      ;;
    *)
      :
      ;;
  esac
done < "$MANIFEST"

# If we restored a backup of ~/bin/sudo, that copy is now back in place.
# If we did NOT restore one but want to remove our wrapper, uncomment the next block:
# if [[ -f "$HOME/bin/sudo" ]]; then
#   rm -f "$HOME/bin/sudo"
#   printf 'Removed wrapper at %s\n' "$HOME/bin/sudo"
# fi

printf 'Backout complete.\n'

Now hit control-x to exit and y to save

Now to execute it!

First we make them executable:

chmod +x install_touchid_sudo.sh uninstall_touchid_sudo.sh
./install_touchid_sudo.sh

Now to load it into our zsh open a new iTerm2 tab or run:

source ~/.zshrc

Then we will test:

sudo -v && echo "sudo cache primed; next sudo should prompt Touch ID if eligible." && sleep 2 && sudo true

If you want to kill it with fire:

./uninstall_touchid_sudo.sh

Lemme know how it goes if you trust me trusting ChatGPT enough to try it!

On my Github:
https://github.com/bionicrocky

I’m Not Crying, You Are

The WiFi professionals community defines that word – community. We have an incredibly active Twitter presence, we have conferences, we have Field Day, we have our own vernacular, we have shared pain unique to our niche. We call each other by our first names and not Twitter handles. It’s a specialty with its own very different challenges. It’s a dual discipline job, half RF nerd and half Network bit jockey. Because of the unique challenges and the tight-knit aspects of the industry anyone in the trenches, I dare say, would answer anyone else’s phone call.

Perhaps the highest honor in this community is the CWNE (Certified Wireless Network Expert) from the excellent training and certification organization, CWNP (Certified Wireless Network Professionals). Why is it the highest? Every other expert level certification in the industry is a combination of proctored tests, some including live labs. They are hard, most of them DAMN hard. CWNE combines four of these tests – difficult ones, with a BUNCH of other stuff. The other stuff is why I’m elated to have been conferred with this thing.

You have to do Pearson-Vue tests, the hard ones. There is the CWNA for table stakes. It’s called an administrator test, it’s an engineer test, flat and simple. Then there’s the CWAP, which is the DEEP packet analysis test. That one nearly killed me in prep. Then the CWDP, the design test. Then the CWSP, the security test. They are 90 minute 60 question tests. You need a 70% to pass. The CWNA/CWSP were a bear when I first got them in 2004. They are as tough now, even having done this kind of work for all of those intervening years (they expired after 3 years and I hadn’t renewed).

So when you pass those it’s all just getting started. Next is three endorsements from people in the field. You also need two other valid certifications, not from CWNP. You have to have three years of verifiable experience specifically in WiFi. You then write three essays of 500-1000 words about projects you’ve worked. Next comes the painful part. You zip it all up and send it to the CWNP. Then you hold your breath for several weeks. You also check your email obsessivly, wake up in cold sweats and annoy your friends as your imposter syndrome goes in to overdrive. During this extended misery the CWNE Board of Advisors does a peer review. They have the opportunity to ask clarifying questions and generally validate that you are worthy of conferral.

Eventually you get an email. If you are me, you basically hang up on your work partner and call your wife crying.

I’ve passed hard tests that span eight hours. I’ve gotten certifications that require verified experience and a long wait. I’ve not, until now, had a certification that involved such subjective validation of my work by my peers and betters. I may still have imposter syndrome, but it has eased up a tiny bit.

 

So You Want To Be A CISSP

Four years verified security experience. An intimidating test. A waiting period that made me lose more hair. This was my CISSP experience. When I took the CISSP it was bubble sheet/Scan Tron. Eight hours for 500 questions from 10 domains ranging from Physical Security to arcane Data Classification used by the military around the time War Games came out. It is, to use an oft used descriptor, a mile wide and an inch deep.

cisspjoke2-300x171

I sat for the test in March of 2006. I self studied. It was, to say the least, intense. Did I make it more intense than I needed to? Probably. I tend to over engineer about anything I can. Usually you can judge your level of study and adequacy of your methods by your test score. Trouble is, you don’t see that in the CISSP.  To the person, everyone I have talked to has the same comment “When I walked out, I had no idea if I had passed or bombed it!” When I took it, I had no computerized option, bubble sheet and #2 pencils only.  It took 3 weeks to find out if I passed the test.  At least that was via email.  Then started the background validation.  That was another 3 weeks.  How did they tell me I passed?  I got an envelope with Rocky Gregory, CISSP on it.  Saw it for the first time.  This was a cert I had wanted since the day I heard about it.  Something I sacrificed for, prepped for and lost a lot of sleep to.  Needless to say, I wept like I was watching Rudy.

One of the questions I get asked most often is what materials I used to study.  It’s important to stop here and note my study process.  Like everything I do, there is a process.

The Resources:

As a rule, I have 3 forms of all of the study materials on any exam.  I have a primary book –  This is the one I read from, mark up, etc.  I use it for the entire study session.  I have a second source – typically the “next best” version.  I do this as people have different writing styles.  They use different analogies.  They use a different tone and assume different levels of skill and background.  If I am baffled by a concept in book 1, I go to book 2 and read it there.  I also tend to take the chapter and content tests out of the second book, rather than the first.  More on that later.  Third –  I have an Exam Cram type book.  One of those skinny, packed with questions, pump and dump type texts.  NOT a brain dump, those are crap and they degrade our industry. I mean the Exam Cram book series. I certify to build my knowledge, renew my understandings, validate I am still mostly sane, and then the letters after my name.  Considering the price of most exams, and the fact that a lot of employers only pay for your first attempt, the test is ultimately fairly important.  Below are the modern versions of the books I used.  I have suggested them for the last 7 years, as well as my study methods and am proud to say the folks I have coached have passed the first time through!

The Books:

FirTheBiblest and foremost, the Shon Harris All-In-One Guide is a must.  This is the Golden Book.  I have known some folks that have used only this resource and passed.

 

Never Go Wrong with SybexNext is good old Sybex. Sybex have been around a dogs age and I have used them since my NT4 MCSE prep.  They are consistently mediocre, but always a good secondary text.  They employ good writers, have a very clean look and feel, and it’s another “voice” to read the text.

 

Cram It!Finally, a good Exam Cram guide for cramming, after chapter testing, and the bare bones answers.

 

 

The Method:

I’m fortunate enough to be a moderate test taker.  I’m extremely fortunate enough to have had a class on another topic taught by my friend and true instructor, ‘‘KC” Keith Charles.  KC taught me study tips that I use to this day, and share with anyone studying for a cert.  I’ve developed a project style preparation system as well.  I tend to put together a project plan for everything I do.  A friend once joked that I can’t refill my water bottle without a plan, process and system.  So, here it goes:

  • From KC, the power and virtue of NERVOUS NOTES.  The nervous notes concept changed my testing life.  The concept is simple.  You are nervous when you sit for a test.  Doesn’t matter who you are, you’ve got a bit of agita.  These notes affirm what you know, give you crib notes for what you don’t.  You write them over and over until it is muscle memory.  It gives you a second applied sense from which to learn, adds some kinesthesia and drives it home in general.  Details on how I use nervous notes:
  • Have a plan for what you will study each session.  “I will finish this malarky about the Orange Books tonight”.  “I will finally be able to explain Elliptical Curve Cryptography to my bulldog by the end of this session”.
  • Read the exam objectives.  Highlight the areas that are going to be troublesome.  Print those, have them somewhere you can see while you study.  Review and check off what you are comfortable with.
  • I really like to read a chapter or concept in one book, then test on it from the end of the chapter in another book.  I do this method until I am hitting in the 80% range, recursively study until I hit that number.  I then test in the primary source and the tertiary.  Once it’s solid, it’s solid.  It goes in the memory bank until the final week or two before the test.  Then I do the whole mugilla, chapter by chapter test.  I will sometimes challenge myself to go back x chapters at the end of a session on an entirely different topic.  With such a theoretical test as the CISSP, this can be a great game to play on yourself.
  • Set study times.  You’re busy.  I’m busy.  Congress is busy.  Get over it, set a specific time.  Lock yourself in a room.  If you dig music and can have it without being distracted, rock that.
  • Set a date and work back.  If you are paper and penciling it, this is pretty easy.  If you are computer basing it, set the date and build your study plan backwards from that date.

Nervous Notes:

  1. Take out an 8.5×11 sheet of paper at the beginning of your study session.
  2. Start making tables, charts, squiggles and notes on the stuff that you are having a hard time with.  For me a good example was EAP types for my CWSP.  Nice little table of type, security level, definition, etc.
  3. After your first session, take out the sheet and refine it, copy it by hand.
  4. Wash, rinse repeat.
  5. As test time gets closer, finish up the notes sheet.  Make a gold image.  Copy it before and after each session, at least once, if not a few times.  Get to where you are NOT thinking as you write it out.  You want to affirm what you know, give crib for what you struggle with and give yourself some time to breath before you hit the begin button or rip open the test book.
  6. Get an 8.5×11 sheet of paper at the test center.  The proctor will give you one and a pencil if you demand it, and as long as you give them the paper back after.  That was my experience any way.  Write out your nervous notes before you tear open the book or hit the start button.  This should relax you, enforce you know what you know and give you that quick reference.

So, that’s what I did.  Again, this may have been, and in fact probably was,  overkill preparation.  All I know is that it worked for me and I got those 5 letters I had wanted for so long.

Why Today Is Important

Alan Turing is credited with creating what we today know as the programmable computer. He had the idea before WWII, but work in earnest started in order to crack the “unbreakable” German Enigma machine’s encryption. They were used on U-boats which were destroying allied ships en-masse. Cracking their code would give locations to avoid and other vital information.

He worked in secret and never got credit for his work in his lifetime because it was still a state secret, though it saved thousands of lives. Many believe it to have been a big part of the reason the Germans surrendered.

He was discovered to be gay, a crime then, and penalized with chemical castration. He took his own life. He was posthumously pardoned in 2013 by the Queen. He is one of my biggest heroes and today is his birthday. Read a book on him or at least watch The Imitation Game. It’s pretty close to factual and you wouldn’t be reading this message if it weren’t for Turing.