Friday, December 18, 2015

TUMPA Mac El Capitan 10.11.2 (FTDI FT2232HL)

    If you want to skip my longwinded journey to finding the fix for this on El Capitan, I understand. However, if you don’t mind a good weaving tale, please feel free to join me for the next few paragraphs below!
TUMPA
    Remember that little TUMPA I was messing with a little while back? I got in a hardware debugging and learning mood, so I decided to fire up my TUMPA board. As a side note, work has since replaced my laptop and I’m no longer running Ubuntu on a Lenovo, but instead I’m on a MacBook Pro. For the most part, the transition has been hardly noticeable. I did what I had always done on Linux, which is to plug that bad boy in and low and behold, NOTHING! Yeah… I had the same reaction, which was disappointment, to say the least. I figured there was no way that Mac wouldn’t be able to plug and play this device when Linux could! Clearly I was very wrong.
    So I headed over to the ol’ Googs for some help. That first link looked quite promising, so I decided to go for it! I simply followed along and downloaded the driver from here. I basically did a normal installation procedure, but if you’re curious I did this:
  • Download DMG
  • Open DMG
  • Double click pkg from opened DMG
  • Look in /System/Library/Extensions/
    • Turns out, El Capitan has non-system kexts installed in /Library/Extensions/… *learned!*
  • ls -l /Library/Extensions/
  • See FTDIUSBSerialDriver.kext
  • Good! Let's plug in the TUMPA
    Plugged the board in, but no change… When I checked kextstat, it returned nothing.
Screen Shot 2015 12 18 at 9 30 58 AM
    Well according to that post, and everything I had read so far, I needed to fire up the kext, so I did what I thought was right and manually loaded that kext.
Screen Shot 2015 12 18 at 10 08 47 AM
    I will tell you that again, I plugged in the device and no change. Now, from this point on, I’ll save you all a little time and just let you know the exact answer I used to fix it. Not the adventure I had while trying to do so, though that IS quite a wonderful story! If you’re curious, just ask and I can post it. It involves many driver attempts, many different drivers, many modifications, and many emails to many support teams.
    The answer actually came from one of my favorite learning resources, irc.freenode.net! I absolutely LOVE IRC. I use xChat Azure on my Mac and I absolutely love every minute of it. I am constantly in a multitude of channels on irc.freenode.net, but mainly I hang out in:
  • #Cisco
  • #Exploiteers
  • #Powershell
  • #Python
  • #Regex
  • #OpenOCD
    I would probably be in more channels than these, but the ones listed are basically the topics I work with almost daily. They are also the rooms that I have found to be the most helpful and welcoming. All of them have been very helpful when I need assistance. I just make sure to read the room rules and ask my questions accordingly. I make sure to always thank the people who take time out of their day to assist me with my questions. If you stop in and see me, Mitch-_-, feel free to say “Hi"! I’ll try to help with anything I can.
    I wanted to make sure to give a major thank you to @PaulFertser on the #OpenOCD IRC.freenode.net channel! He really is a very helpful resource. He helped me get OpenOCD installed and walked me through getting it working for JTAG. Then I could confirm that that the JTAG portion was at least connected and working using libusb. The last remaining part was not necessarily Paul's wheelhouse, but he did suggest a blog post that helped point me in the right direction. It was ultimately the turning point to getting the driver working properly! Thanks again, Paul!

    To get this working, I had to combine both steps from the tiaowiki.com install TUMPA on a Mac, and this Mommosoft Blog. The combination was editing the Info.plist in the steps from the wiki, but in the blog post, he lists the "bcdDevice" id as being a critical item to include. When looking in the Info.plist, I did notice that it was on all <key> entries... I figured that must have been my missing item, because the TIAO wiki does not list the "bdcDevice" in it's entries.
    To edit your FTDI kernel extension, open a terminal and enter:

1
sudo nano /Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist
       Once inside this Info.plist via nano, you can search by using CTRL+W. By using that key combination, I searched for “1792", which is the bcdDevice ID for FT2232H chips. I believe that is just the bcdDevice ID for all FTDI FT2232H chips, not 100% positive on that though. It was listed on almost every one of them, so that was promising. I then used CTRL+W to find “FT2232H”, which was just a good starting place to put my <key> information. I decided to put it between FT2232H_A and FT2232H_B.
    I then entered the two new following keys:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<key>FT2232H-TIAO-0</key>
    <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>1792</integer>
        <key>idProduct</key>
        <integer>35480</integer>
        <key>idVendor</key>
        <integer>1027</integer>
    </dict>
    <key>FT2232H-TIAO-1</key>
    <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>1</integer>
        <key>bcdDevice</key>
        <integer>1792</integer>
        <key>idProduct</key>
        <integer>35480</integer>
        <key>idVendor</key>
        <integer>1027</integer>
    </dict>
Warning: Lengthy explination on how to get idVendor, idProduct, and bcdDevice.

    After you modify the Info.plist, you will need to remove SIP (System Integrity Protection), which is a new feature in the world of Mac. It’s a security feature that is turned on by default in El Capitan. When you go to use a driver(kext) that has not been signed, it will not allow it to start. When we added the entries into the Info.plist, you have changed the contents so the kext is no longer signed. Therefore, you will need to disable SIP.
    Verify if SIP is enabled or disabled with
1
csrutil status
    If SIP is already disabled, you can proceed to reboot and loading the kext. The process for disabling SIP is outlined here. Disabling SIP requires a reboot (and so does installing the kext and changing the Info.plist, so there will be no shortages of reboots in this process). After disabling SIP and rebooting, you will need to manually load the kext.
1
sudo kextload /Library/Extensions/FTDIUSBSerialDriver.kext
    Once you have the device plugged in and the kext loaded from the command above, you can run ls for the device.

1
ls -l /dev/tty.*
    You should see something along the lines of this. (I know this picture is for cu.*, I was just learning at the time that tty was what I needed…)
Screen Shot 2015 12 14 at 4 47 53 PM
    Clearly, the “bcdDevice” was the key to getting the TUMPA recognized, which is a missing field from the tiaowiki article! Once we have that device recognized, we will either use Channel A or Channel B depending on your use case. As stated in the TUMPA Manual, TTL will be using Channel B. It’s listed under Board Dimensions at the bottom of that specific article.
    From your terminal window, you can now type “minicom -s” and it will prompt you for setting up your minicom connection. You will need to set the device to "/dev/tty.usbserial-TIM0394B” if you are going to be using TTL for loopback testing, which is what I am doing. Save your configuration as “tumpa” for ease of use.
    Please Note: My board was already in TTL loopback mode from previous testing, if you need to put yours in TTL loopback mode. Please see the article I have posted at tiaowiki.
    HINT: If you would like to have a shortcut to your configuration with minicom, you can add an alias. Such as:

1
alias tumpa='minicom tumpa'
or

1
alias tumpa=‘sudo minicom tumpa'
    You will enter either one, depending on your use case. I usually prefer to run minicom with sudo, even though I have very few reasons to do so. Regardless, now we can use our alias and fire up minicom!
Screen Shot 2015 12 18 at 1 20 55 PM
    From here, you should be able to use minicom as you would have on Linux or any platform that has it, and test typing with the device showing activity and the output showing back up on screen as is. I hope this has been helpful for anyone that has tried to use a TUMPA on a Mac with El Capitan. Along those lines, I hope this is helpful for anyone that has a unique PID with their FTDI FT2232HL chip, because these directions should work for that as well! Until next time, thank you for reading!

-Mitch B.

Friday, November 13, 2015

Fixed Batch and Powershell Syntax Highlighting

     Somehow, over the last few days I've gotten back into nano editor. It was then I realized, that when I had switched to my Mac, I had never used the bat.nanorc or powershell.nanorc files that I had created in my last post! Well that was silly! So I fired up the ol terminal, got em copied to the right location and went to go use it and for some reason... it wasn't working. Well that was because I was using native nano... 2.0.6 I think. And that was TOO old to use syntax highlighting. So I updated, tested with the files and checked, tada! We were good.

     Then I went about testing it a bit and thought, yeah this is pretty good! I will just send these over to the nano-deldev team at nano-editor.org. Long story short I got my hand slapped PRETTY good. They pretty much showed me that I was no where near ready to publish these. So I set about fixing these and these are the final results. 

BATCH:
------------------------------------------------------------
##
syntax "batch" "\.(bat|cmd)$"

## Parameters that are normally %x in cmd
icolor brightred "%%."

## Major statements
icolor red "\<(do|else|exist|exit|for|goto|if|not|return|say|select|then|when)\>"
icolor brightcyan "\<(ansi|append|assign|assoc|attrib|at|autofail|backup|basedev|boot|break|buffers|cache|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|codepage|color|command|compact|comp|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|rename|ren|replace|restore|rmdir|run|set|setboot|setlocal|shift|sort|start|subst|time|title|trapdump|tree|type|undelete|unpack|use|verify|ver|vol|xcopy)\>"

## Call for a batch file or subroutine
icolor magenta "^call :?[:alnum:].*$"

## Comparison operators
icolor brightmagenta "\<(equ|neq|gtr|lss|geq|leq)\>"
color brightyellow "=="

## Comments
icolor brightblue "(^[[:space:]]*(\<rem\>|::).*$)"

## Quoted text
icolor brightwhite ""[^"]*""

## Variables
icolor yellow "\%[a-zA-Z_]+[:alnum:]*[0-9]?\%"

## Trailling whitespace
color ,green "[[:space:]]+$"

------------------------------------------------------------


     As you can tell, that is a much cleaner and shorter version from my original. I have learned QUITE a bit of POSIX regex because of these silly little files. BUT I personally think they look much better. And to be honest, if I use them enough and need to change something, I can do it more freely now!


POWERSHELL:
------------------------------------------------------------
##
syntax "powershell" "\.(ps1|psm1)$"

## Most commands
icolor cyan "\<(Add-Computer|Add-Content|Add-History|Add-Member|Add-PSSnapin|Add-Type|asnp|cat|cd|cd..|chdir|Checkpoint-Co|clc|clear|Clear-Content|Clear-EventLo|Clear-History|Clear-Host|Clear-Item|Clear-ItemPro|Clear-Variabl|clhy|cli|clp|cls|clv|compare|Compare-Objec|Complete-Tran|Connect-WSMan|ConvertFrom-C|ConvertFrom-S|ConvertFrom-S|Convert-Path|ConvertTo-Csv|ConvertTo-Htm|ConvertTo-Sec|ConvertTo-Xml|copy|Copy-Item|Copy-ItemProp|cp|cpi|cpp|cvpa|dbp|Debug-Process|del|diff|dir|Disable-Compu|Disable-PSBre|Disable-PSRem|Disable-PSSes|Disable-WSMan|Disconnect-WS|ebp|echo|Enable-Comput|Enable-PSBrea|Enable-PSRemo|Enable-PSSess|Enable-WSManC|Enter-PSSessi|epal|epcsv|epsn|erase|etsn|Exit-PSSessio|Export-Alias|Export-Clixml|Export-Consol|Export-Counte|Export-Csv|Export-Format|Export-Module|Export-PSSess|exsn|foreach|ForEach-Objec|Format-Custom|Format-List|Format-Table|Format-Wide|gal|gbp|gc|gci|gcm|gcs|gdr|Get-Acl|Get-Alias|Get-Authentic|Get-ChildItem|Get-Command|Get-ComputerR|Get-Content|Get-Counter|Get-Credentia|Get-Culture|Get-Date|Get-Event|Get-EventLog|Get-EventSubs|Get-Execution|Get-FormatDat|Get-Help|Get-History|Get-Host|Get-HotFix|Get-Item|Get-ItemPrope|Get-Job|Get-Location|Get-Member|Get-Module|Get-PfxCertif|Get-Process|Get-PSBreakpo|Get-PSCallSta|Get-PSDrive|Get-PSProvide|Get-PSSession|Get-PSSession|Get-PSSnapin|Get-Random|Get-Service|Get-TraceSour|Get-Transacti|Get-UICulture|Get-Unique|Get-Variable|Get-Verb|Get-WinEvent|Get-WmiObject|Get-WSManCred|Get-WSManInst|ghy|gjb|gmo|gps|group|Group-Object|gsn|gsnp|gsv|gwmi|help|history|icm|iex|ihy|Import-Alias|Import-Clixml|Import-Counte|Import-Csv|Import-Locali|Import-Module|Import-PSSess|ImportSystemM|Invoke-Comman|Invoke-Expres|Invoke-Histor|Invoke-Item|Invoke-WmiMet|Invoke-WSManA|ipal|ipcsv|ipmo|ipsn|ise|iwmi|Join-Path|kill|Limit-EventLo|man|measure|Measure-Comma|Measure-Objec|mkdir|more|mount|move|Move-Item|Move-ItemProp|mv|nal|ndr|New-Alias|New-Event|New-EventLog|New-Item|New-ItemPrope|New-Module|New-ModuleMan|New-Object|New-PSDrive|New-PSSession|New-PSSession|New-Service|New-TimeSpan|New-Variable|New-WebServic|New-WSManInst|New-WSManSess|nmo|nsn|ogv|Out-Default|Out-File|Out-GridView|Out-Host|Out-Null|Out-Printer|Out-String|popd|Pop-Location|prompt|pushd|Push-Location|pwd|rbp|rcjb|rdr|Read-Host|Receive-Job|Register-Engi|Register-Obje|Register-PSSe|Register-WmiE|Remove-Comput|Remove-Event|Remove-EventL|Remove-Item|Remove-ItemPr|Remove-Job|Remove-Module|Remove-PSBrea|Remove-PSDriv|Remove-PSSess|Remove-PSSnap|Remove-Variab|Remove-WmiObj|Remove-WSManI|ren|Rename-Item|Rename-ItemPr|Reset-Compute|Resolve-Path|Restart-Compu|Restart-Servi|Restore-Compu|Resume-Servic|rjb|rmdir|rmo|rni|rnp|rsn|rsnp|rvpa|rwmi|sajb|sal|saps|sasv|sbp|select|Select-Object|Select-String|Select-Xml|Send-MailMess|set|Set-Acl|Set-Alias|Set-Authentic|Set-Content|Set-Date|Set-Execution|Set-Item|Set-ItemPrope|Set-Location|Set-PSBreakpo|Set-PSDebug|Set-PSSession|Set-Service|Set-StrictMod|Set-TraceSour|Set-Variable|Set-WmiInstan|Set-WSManInst|Set-WSManQuic|Show-EventLog|sleep|sort|Sort-Object|spjb|Split-Path|spps|spsv|start|Start-Job|Start-Process|Start-Service|Start-Sleep|Start-Transac|Start-Transcr|Stop-Computer|Stop-Job|Stop-Process|Stop-Service|Stop-Transcri|Suspend-Servi|swmi|TabExpansion|tee|Tee-Object|Test-Computer|Test-Connecti|Test-ModuleMa|Test-Path|Test-WSMan|Trace-Command|type|Undo-Transact|Unregister-Ev|Unregister-PS|Update-Format|Update-List|Update-TypeDa|Use-Transacti|Wait-Event|Wait-Job|Wait-Process|where|Where-Object|wjb|write|Write-Debug|Write-Error|Write-EventLo|Write-Host|Write-Output|Write-Progres|Write-Verbose|Write-Warning)\>"

## Functions
icolor brightyellow "\<(function)\>"

## Comparison operators
icolor brightyellow "-\<(eq|ne|gt|lt|ge|le)\>"

## Variables
icolor brightred "(\$[a-zA-Z0-9_]+)"

## Major statements
icolor brightcyan "\<(if|do|else|elseif|for|foreach|switch|until|while)\>"

## Comments
color brightblue "(^)?(([[:space:]]?)+)#.*$"

## Quoted text
color brightwhite "\".*\""
color brightwhite "\'.*\'"

## Text between %'s which is unique to searches
icolor brightmagenta "\%.*\%"

------------------------------------------------------------


     As you can tell, these are still quite long, but unfortunately they will have to be because of all of the commandlets. For the most part though, these are much cleaner and should work much better than before. I have even changed a few things that I hadn't thought about the first time. I worked with @OnlineCop on IRC-Freenode's #regex channel. He deserves credit for almost all of the teaching! If anyone is interested in learning about how these work, please feel free to hit me up and I'll try to rack my brain to try to help! 

As for these files, you can get them from https://github.com/mitchell486/nanorc or from the lines above. I'm not positive if these will work on nano for windows, but maybe I'll test that later. (I did have one person hit me up one time for these and was going to use them on windows, but I'm not sure if they ever worked as expected or not.)

-Mitch

Sunday, May 11, 2014

Batch and Powershell Nano Syntax Highlighting

NOTE: Please see my better, shorter, and updated versions here.

Another quick update for the few that may venture into this... I've recently had a few quirks when trying to read batch and powershell files in nano on Linux.... I love my Nano editor but it doesn't have nanorc files for syntax highlighting regarding Batch or Powershell. Heck, who can blame them! Windblows? No thanks! Yuck!

But sadly... That's not how the real world works so... I had to write my own to get it to work since apparently no on one on the internet has ever made them for nano.

## Here is an example for Batch scripts.
## CREATED BY MITCH BUMGARNER ON MAY 10TH 2014

syntax "bat" "\.(bat|cmd)$"
icolor brightred "%%."
icolor red "(do|else|exist|exit|for|goto|if|not|return|say|select|then|when)"
icolor magenta "^call :?[a-zA-Z0-9_].*$"
icolor brightmagenta "([[:space:]]equ[[:space:]]|[[:space:]]neq[[:space:]]|[[:space:]]gtr[[:space:]]|[[:space:]]lss[[:space:]]|[[:space:]]geq[[:space:]]|[[:space:]]leq[[:space:]])"
color brightyellow "=="
icolor brightcyan "(ansi|append|assign|assoc|attrib|at|autofail|backup|basedev|boot|break|buffers|cache|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|codepage|color|command|compact|comp|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|rename|ren|replace|restore|rmdir|run|set|setboot|setlocal|shift|sort|start|subst|time|title|trapdump|tree|type|undelete|unpack|use|verify|ver|vol|xcopy)"
icolor brightblue "^rem.*$"
color cyan "[[:space:]]?::.*$"
icolor brightwhite ""[^"]*"" 
icolor yellow "[[:space:]]\%.*%[[:space:]]"





## Here is an example for Powershell scripts.

##
syntax "bat" "\.(ps1|psm1)$"
icolor brightred "([[:space:]]Add-Computer[[:space:]]|[[:space:]]Add-Content[[:space:]]|[[:space:]]Add-History[[:space:]]|[[:space:]]Add-Member[[:space:]]|[[:space:]]Add-PSSnapin[[:space:]]|[[:space:]]Add-Type[[:space:]]|[[:space:]]asnp[[:space:]]|[[:space:]]cat[[:space:]]|[[:space:]]cd[[:space:]]|[[:space:]]cd..[[:space:]]|[[:space:]]chdir[[:space:]]|[[:space:]]Checkpoint-Co[[:space:]]|[[:space:]]clc[[:space:]]|[[:space:]]clear[[:space:]]|[[:space:]]Clear-Content[[:space:]]|[[:space:]]Clear-EventLo[[:space:]]|[[:space:]]Clear-History[[:space:]]|[[:space:]]Clear-Host[[:space:]]|[[:space:]]Clear-Item[[:space:]]|[[:space:]]Clear-ItemPro[[:space:]]|[[:space:]]Clear-Variabl[[:space:]]|[[:space:]]clhy[[:space:]]|[[:space:]]cli[[:space:]]|[[:space:]]clp[[:space:]]|[[:space:]]cls[[:space:]]|[[:space:]]clv[[:space:]]|[[:space:]]compare[[:space:]]|[[:space:]]Compare-Objec[[:space:]]|[[:space:]]Complete-Tran[[:space:]]|[[:space:]]Connect-WSMan[[:space:]]|[[:space:]]ConvertFrom-C[[:space:]]|[[:space:]]ConvertFrom-S[[:space:]]|[[:space:]]ConvertFrom-S[[:space:]]|[[:space:]]Convert-Path[[:space:]]|[[:space:]]ConvertTo-Csv[[:space:]]|[[:space:]]ConvertTo-Htm[[:space:]]|[[:space:]]ConvertTo-Sec[[:space:]]|[[:space:]]ConvertTo-Xml[[:space:]]|[[:space:]]copy[[:space:]]|[[:space:]]Copy-Item[[:space:]]|[[:space:]]Copy-ItemProp[[:space:]]|[[:space:]]cp[[:space:]]|[[:space:]]cpi[[:space:]]|[[:space:]]cpp[[:space:]]|[[:space:]]cvpa[[:space:]]|[[:space:]]dbp[[:space:]]|[[:space:]]Debug-Process[[:space:]]|[[:space:]]del[[:space:]]|[[:space:]]diff[[:space:]]|[[:space:]]dir[[:space:]]|[[:space:]]Disable-Compu[[:space:]]|[[:space:]]Disable-PSBre[[:space:]]|[[:space:]]Disable-PSRem[[:space:]]|[[:space:]]Disable-PSSes[[:space:]]|[[:space:]]Disable-WSMan[[:space:]]|[[:space:]]Disconnect-WS[[:space:]]|[[:space:]]ebp[[:space:]]|[[:space:]]echo[[:space:]]|[[:space:]]Enable-Comput[[:space:]]|[[:space:]]Enable-PSBrea[[:space:]]|[[:space:]]Enable-PSRemo[[:space:]]|[[:space:]]Enable-PSSess[[:space:]]|[[:space:]]Enable-WSManC[[:space:]]|[[:space:]]Enter-PSSessi[[:space:]]|[[:space:]]epal[[:space:]]|[[:space:]]epcsv[[:space:]]|[[:space:]]epsn[[:space:]]|[[:space:]]erase[[:space:]]|[[:space:]]etsn[[:space:]]|[[:space:]]Exit-PSSessio[[:space:]]|[[:space:]]Export-Alias[[:space:]]|[[:space:]]Export-Clixml[[:space:]]|[[:space:]]Export-Consol[[:space:]]|[[:space:]]Export-Counte[[:space:]]|[[:space:]]Export-Csv[[:space:]]|[[:space:]]Export-Format[[:space:]]|[[:space:]]Export-Module[[:space:]]|[[:space:]]Export-PSSess[[:space:]]|[[:space:]]exsn[[:space:]]|[[:space:]]foreach[[:space:]]|[[:space:]]ForEach-Objec[[:space:]]|[[:space:]]Format-Custom[[:space:]]|[[:space:]]Format-List[[:space:]]|[[:space:]]Format-Table[[:space:]]|[[:space:]]Format-Wide[[:space:]]|[[:space:]]gal[[:space:]]|[[:space:]]gbp[[:space:]]|[[:space:]]gc[[:space:]]|[[:space:]]gci[[:space:]]|[[:space:]]gcm[[:space:]]|[[:space:]]gcs[[:space:]]|[[:space:]]gdr[[:space:]]|[[:space:]]Get-Acl[[:space:]]|[[:space:]]Get-Alias[[:space:]]|[[:space:]]Get-Authentic[[:space:]]|[[:space:]]Get-ChildItem[[:space:]]|[[:space:]]Get-Command[[:space:]]|[[:space:]]Get-ComputerR[[:space:]]|[[:space:]]Get-Content[[:space:]]|[[:space:]]Get-Counter[[:space:]]|[[:space:]]Get-Credentia[[:space:]]|[[:space:]]Get-Culture[[:space:]]|[[:space:]]Get-Date[[:space:]]|[[:space:]]Get-Event[[:space:]]|[[:space:]]Get-EventLog[[:space:]]|[[:space:]]Get-EventSubs[[:space:]]|[[:space:]]Get-Execution[[:space:]]|[[:space:]]Get-FormatDat[[:space:]]|[[:space:]]Get-Help[[:space:]]|[[:space:]]Get-History[[:space:]]|[[:space:]]Get-Host[[:space:]]|[[:space:]]Get-HotFix[[:space:]]|[[:space:]]Get-Item[[:space:]]|[[:space:]]Get-ItemPrope[[:space:]]|[[:space:]]Get-Job[[:space:]]|[[:space:]]Get-Location[[:space:]]|[[:space:]]Get-Member[[:space:]]|[[:space:]]Get-Module[[:space:]]|[[:space:]]Get-PfxCertif[[:space:]]|[[:space:]]Get-Process[[:space:]]|[[:space:]]Get-PSBreakpo[[:space:]]|[[:space:]]Get-PSCallSta[[:space:]]|[[:space:]]Get-PSDrive[[:space:]]|[[:space:]]Get-PSProvide[[:space:]]|[[:space:]]Get-PSSession[[:space:]]|[[:space:]]Get-PSSession[[:space:]]|[[:space:]]Get-PSSnapin[[:space:]]|[[:space:]]Get-Random[[:space:]]|[[:space:]]Get-Service[[:space:]]|[[:space:]]Get-TraceSour[[:space:]]|[[:space:]]Get-Transacti[[:space:]]|[[:space:]]Get-UICulture[[:space:]]|[[:space:]]Get-Unique[[:space:]]|[[:space:]]Get-Variable[[:space:]]|[[:space:]]Get-Verb[[:space:]]|[[:space:]]Get-WinEvent[[:space:]]|[[:space:]]Get-WmiObject[[:space:]]|[[:space:]]Get-WSManCred[[:space:]]|[[:space:]]Get-WSManInst[[:space:]]|[[:space:]]ghy[[:space:]]|[[:space:]]gjb[[:space:]]|[[:space:]]gmo[[:space:]]|[[:space:]]gps[[:space:]]|[[:space:]]group[[:space:]]|[[:space:]]Group-Object[[:space:]]|[[:space:]]gsn[[:space:]]|[[:space:]]gsnp[[:space:]]|[[:space:]]gsv[[:space:]]|[[:space:]]gwmi[[:space:]]|[[:space:]]help[[:space:]]|[[:space:]]history[[:space:]]|[[:space:]]icm[[:space:]]|[[:space:]]iex[[:space:]]|[[:space:]]ihy[[:space:]]|[[:space:]]Import-Alias[[:space:]]|[[:space:]]Import-Clixml[[:space:]]|[[:space:]]Import-Counte[[:space:]]|[[:space:]]Import-Csv[[:space:]]|[[:space:]]Import-Locali[[:space:]]|[[:space:]]Import-Module[[:space:]]|[[:space:]]Import-PSSess[[:space:]]|[[:space:]]ImportSystemM[[:space:]]|[[:space:]]Invoke-Comman[[:space:]]|[[:space:]]Invoke-Expres[[:space:]]|[[:space:]]Invoke-Histor[[:space:]]|[[:space:]]Invoke-Item[[:space:]]|[[:space:]]Invoke-WmiMet[[:space:]]|[[:space:]]Invoke-WSManA[[:space:]]|[[:space:]]ipal[[:space:]]|[[:space:]]ipcsv[[:space:]]|[[:space:]]ipmo[[:space:]]|[[:space:]]ipsn[[:space:]]|[[:space:]]ise[[:space:]]|[[:space:]]iwmi[[:space:]]|[[:space:]]Join-Path[[:space:]]|[[:space:]]kill[[:space:]]|[[:space:]]Limit-EventLo[[:space:]]|[[:space:]]man[[:space:]]|[[:space:]]measure[[:space:]]|[[:space:]]Measure-Comma[[:space:]]|[[:space:]]Measure-Objec[[:space:]]|[[:space:]]mkdir[[:space:]]|[[:space:]]more[[:space:]]|[[:space:]]mount[[:space:]]|[[:space:]]move[[:space:]]|[[:space:]]Move-Item[[:space:]]|[[:space:]]Move-ItemProp[[:space:]]|[[:space:]]mv[[:space:]]|[[:space:]]nal[[:space:]]|[[:space:]]ndr[[:space:]]|[[:space:]]New-Alias[[:space:]]|[[:space:]]New-Event[[:space:]]|[[:space:]]New-EventLog[[:space:]]|[[:space:]]New-Item[[:space:]]|[[:space:]]New-ItemPrope[[:space:]]|[[:space:]]New-Module[[:space:]]|[[:space:]]New-ModuleMan[[:space:]]|[[:space:]]New-Object[[:space:]]|[[:space:]]New-PSDrive[[:space:]]|[[:space:]]New-PSSession[[:space:]]|[[:space:]]New-PSSession[[:space:]]|[[:space:]]New-Service[[:space:]]|[[:space:]]New-TimeSpan[[:space:]]|[[:space:]]New-Variable[[:space:]]|[[:space:]]New-WebServic[[:space:]]|[[:space:]]New-WSManInst[[:space:]]|[[:space:]]New-WSManSess[[:space:]]|[[:space:]]nmo[[:space:]]|[[:space:]]nsn[[:space:]]|[[:space:]]ogv[[:space:]]|[[:space:]]Out-Default[[:space:]]|[[:space:]]Out-File[[:space:]]|[[:space:]]Out-GridView[[:space:]]|[[:space:]]Out-Host[[:space:]]|[[:space:]]Out-Null[[:space:]]|[[:space:]]Out-Printer[[:space:]]|[[:space:]]Out-String[[:space:]]|[[:space:]]popd[[:space:]]|[[:space:]]Pop-Location[[:space:]]|[[:space:]]prompt[[:space:]]|[[:space:]]pushd[[:space:]]|[[:space:]]Push-Location[[:space:]]|[[:space:]]pwd[[:space:]]|[[:space:]]rbp[[:space:]]|[[:space:]]rcjb[[:space:]]|[[:space:]]rdr[[:space:]]|[[:space:]]Read-Host[[:space:]]|[[:space:]]Receive-Job[[:space:]]|[[:space:]]Register-Engi[[:space:]]|[[:space:]]Register-Obje[[:space:]]|[[:space:]]Register-PSSe[[:space:]]|[[:space:]]Register-WmiE[[:space:]]|[[:space:]]Remove-Comput[[:space:]]|[[:space:]]Remove-Event[[:space:]]|[[:space:]]Remove-EventL[[:space:]]|[[:space:]]Remove-Item[[:space:]]|[[:space:]]Remove-ItemPr[[:space:]]|[[:space:]]Remove-Job[[:space:]]|[[:space:]]Remove-Module[[:space:]]|[[:space:]]Remove-PSBrea[[:space:]]|[[:space:]]Remove-PSDriv[[:space:]]|[[:space:]]Remove-PSSess[[:space:]]|[[:space:]]Remove-PSSnap[[:space:]]|[[:space:]]Remove-Variab[[:space:]]|[[:space:]]Remove-WmiObj[[:space:]]|[[:space:]]Remove-WSManI[[:space:]]|[[:space:]]ren[[:space:]]|[[:space:]]Rename-Item[[:space:]]|[[:space:]]Rename-ItemPr[[:space:]]|[[:space:]]Reset-Compute[[:space:]]|[[:space:]]Resolve-Path[[:space:]]|[[:space:]]Restart-Compu[[:space:]]|[[:space:]]Restart-Servi[[:space:]]|[[:space:]]Restore-Compu[[:space:]]|[[:space:]]Resume-Servic[[:space:]]|[[:space:]]rjb[[:space:]]|[[:space:]]rmdir[[:space:]]|[[:space:]]rmo[[:space:]]|[[:space:]]rni[[:space:]]|[[:space:]]rnp[[:space:]]|[[:space:]]rsn[[:space:]]|[[:space:]]rsnp[[:space:]]|[[:space:]]rvpa[[:space:]]|[[:space:]]rwmi[[:space:]]|[[:space:]]sajb[[:space:]]|[[:space:]]sal[[:space:]]|[[:space:]]saps[[:space:]]|[[:space:]]sasv[[:space:]]|[[:space:]]sbp[[:space:]]|[[:space:]]select[[:space:]]|[[:space:]]Select-Object[[:space:]]|[[:space:]]Select-String[[:space:]]|[[:space:]]Select-Xml[[:space:]]|[[:space:]]Send-MailMess[[:space:]]|[[:space:]]set[[:space:]]|[[:space:]]Set-Acl[[:space:]]|[[:space:]]Set-Alias[[:space:]]|[[:space:]]Set-Authentic[[:space:]]|[[:space:]]Set-Content[[:space:]]|[[:space:]]Set-Date[[:space:]]|[[:space:]]Set-Execution[[:space:]]|[[:space:]]Set-Item[[:space:]]|[[:space:]]Set-ItemPrope[[:space:]]|[[:space:]]Set-Location[[:space:]]|[[:space:]]Set-PSBreakpo[[:space:]]|[[:space:]]Set-PSDebug[[:space:]]|[[:space:]]Set-PSSession[[:space:]]|[[:space:]]Set-Service[[:space:]]|[[:space:]]Set-StrictMod[[:space:]]|[[:space:]]Set-TraceSour[[:space:]]|[[:space:]]Set-Variable[[:space:]]|[[:space:]]Set-WmiInstan[[:space:]]|[[:space:]]Set-WSManInst[[:space:]]|[[:space:]]Set-WSManQuic[[:space:]]|[[:space:]]Show-EventLog[[:space:]]|[[:space:]]sleep[[:space:]]|[[:space:]]sort[[:space:]]|[[:space:]]Sort-Object[[:space:]]|[[:space:]]spjb[[:space:]]|[[:space:]]Split-Path[[:space:]]|[[:space:]]spps[[:space:]]|[[:space:]]spsv[[:space:]]|[[:space:]]start[[:space:]]|[[:space:]]Start-Job[[:space:]]|[[:space:]]Start-Process[[:space:]]|[[:space:]]Start-Service[[:space:]]|[[:space:]]Start-Sleep[[:space:]]|[[:space:]]Start-Transac[[:space:]]|[[:space:]]Start-Transcr[[:space:]]|[[:space:]]Stop-Computer[[:space:]]|[[:space:]]Stop-Job[[:space:]]|[[:space:]]Stop-Process[[:space:]]|[[:space:]]Stop-Service[[:space:]]|[[:space:]]Stop-Transcri[[:space:]]|[[:space:]]Suspend-Servi[[:space:]]|[[:space:]]swmi[[:space:]]|[[:space:]]TabExpansion[[:space:]]|[[:space:]]tee[[:space:]]|[[:space:]]Tee-Object[[:space:]]|[[:space:]]Test-Computer[[:space:]]|[[:space:]]Test-Connecti[[:space:]]|[[:space:]]Test-ModuleMa[[:space:]]|[[:space:]]Test-Path[[:space:]]|[[:space:]]Test-WSMan[[:space:]]|[[:space:]]Trace-Command[[:space:]]|[[:space:]]type[[:space:]]|[[:space:]]Undo-Transact[[:space:]]|[[:space:]]Unregister-Ev[[:space:]]|[[:space:]]Unregister-PS[[:space:]]|[[:space:]]Update-Format[[:space:]]|[[:space:]]Update-List[[:space:]]|[[:space:]]Update-TypeDa[[:space:]]|[[:space:]]Use-Transacti[[:space:]]|[[:space:]]Wait-Event[[:space:]]|[[:space:]]Wait-Job[[:space:]]|[[:space:]]Wait-Process[[:space:]]|[[:space:]]where[[:space:]]|[[:space:]]Where-Object[[:space:]]|[[:space:]]wjb[[:space:]]|[[:space:]]write[[:space:]]|[[:space:]]Write-Debug[[:space:]]|[[:space:]]Write-Error[[:space:]]|[[:space:]]Write-EventLo[[:space:]]|[[:space:]]Write-Host[[:space:]]|[[:space:]]Write-Output[[:space:]]|[[:space:]]Write-Progres[[:space:]]|[[:space:]]Write-Verbose[[:space:]]|[[:space:]]Write-Warning[[:space:]])"
icolor brightyellow "function[[:space:]]"
icolor brightyellow "-(eq[[:space:]]|ne[[:space:]]|gt[[:space:]]|lt[[:space:]]|ge[[:space:]]|le[[:space:]])"
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color brightblue "^[[:space:]]?#.*$"
icolor brightwhite ""[^"]*""
icolor yellow "[[:space:]]\%.*%[[:space:]]"
icolor brightcyan "([[:space:]]?if[[:space:]]|[[:space:]]?do[[:space:]]|[[:space:]]?else[[:space:]]|[[:space:]]?elseif[[:space:]]|[[:space:]]?for[[:space:]]|[[:space:]]?foreach[[:space:]]|[[:space:]]?switch[[:space:]]|[[:space:]]?until[[:space:]]|[[:space:]]?while[[:space:]])"



Clearly the first one is for batch files and the second for Powershell. The hardest part of this was getting better at regex! Once I got around that hurdle, it was a bit easier. Also, sorry for including so many commandlets in the powershell one but.... I wanted to have decent highlighting for keywords so... I made that work. The key to making them work was having them highlighted only if they are stand-alone keywords... I know they won't currently highlight if they are the start of a line, but it was better to do it this way. They are super long and I think it should be noted that in between each quote and parenthasis should be a single line when you paste this into a text editor for saving. 

To save, you simply copy the text I have here into a file, then save that file in /usr/share/nano/batch.nanorc and also /usr/share/nano/powershell.nanorc.

Then to get them included into your nano, you need to edit /etc/nanorc and navigate to the bottom where it says "## Nanorc files".... then include /usr/share/nano/nanorc.nanorc.... it's saying Read this .nanorc file when you run for syntax highlighting... Well we want to add our two files into that list. Once that's done. Close it up. Fire up nano with a batch file or a powershell file and test away! You can tweak these colors and settings to make them match what you want but, hopefully I've done most of the hard work for you.

Overall, I hope this was helpful to anyone that may need them and if anyone has any questions regarding them, please feel free to contact me! You can either comment on here or email me and I'll try my best to answer!


-Mitch

EDIT: There is a much cleaner version at https://github.com/mitchell486/nanorc

Thursday, April 10, 2014

TUMPA

Sorry for the long absence of a post. Life gets crazy sometimes.

Tonight, we make up for that with a little awesome device I got for my birthday called the "TUMPA". TIAO USB Multi-Protocol Adapter. This little guy is powerful. I've only used it a little bit but I like it already. Best $30 I've spent. This isn't where I got mine, but it's the same price. The device can be a bit daunting if you've never messed with UART, JTAG, or anything of the sort before. So I wrote a small tutorial on getting started with this device and minicom on Linux.

To give someone a good starting place with the TUMPA device.

On a Linux system to get a decent start and test to make sure your TUMPA board is working. Mine is for Ubuntu 12.04 x64.



Read http://www.tiaowiki.com/w/TIAO_USB_Multi_Protocol_Adapter_User's_Manual as you go along. It is actually quite helpful along with this starter guide.
To start, you will need to move the 3x8 TTL-COM jumpers from the default position of "Top Row & Middle Row" if you are following the guide... to the new position of "Middle Row & Bottom Row" to put the RS232 TTL-OUT as active. Once you have done that, remove the jumper from the Upper RS232 "c60" postion where it is currently located at 5&6, and place it on pin 1&2 on the TTL-COM row (or the 2x6 TTL) located at the bottom of the board. Once you have done this, your board is now in "Self test" mode or "loopback".

Essentially what we have done here is take the TTL section that is 3x8 TTL and made it go from "SELECT" mode, to "TTL-OUT" mode.... Meaning it will now utilize the bottom row of TTL-COM pins or the 2x6 TTL pins. Once you have selected to use those... We needed to set the TX(send) and RX(receive) to speak so that we could test the loopback functionality of the device. If you read in the manual, pins 5&6 on the upper RS232 "c60" pins are the TX and RX pins, while pins 1&2 are the TX and RX pins for the lower 2x6 TTL pins. These are all documented in the manual.



Once you hook your TUMPA via USB to your system, run

Code: [Select]
dmesg | grep USB. Verify that the output toward the end says that the "FTDI device is attached at ttyUSB0". Next, get minicom by running
Code: [Select]
sudo apt-get install minicom
Once minicom is installed, from your terminal window,

Code: [Select]
minicomIt will then be at an almost blank screen with very little information. Minicom is pretty easy to navigate once you get used to it. To start, make sure minicom is set to read the /dev/ttyUSB0 device. And the settings for the TUMPA serial test are either 115200 8N1 or 9600 8N1. To set these settings within minicom, use the key combo Ctrl+A, then press Z to access the menu (note: a shortcut for it is Ctrl+A, Then the letter of the shortcut, in our example... it's O.).... So from that menu... You will need to press O unless you used the shortcut. Once in that menu, you will need to select the option "Serial Port Setup". Once in that sub-menu, select E for Bps/Par/Bits. And from there you can either set it to 115200 or 9600 (C or E), and then Q for 8N1. You can exit that menu. Saving it is recommended. While in there, you can verify that /dev/ttyUSB0 is set as well. NOTE: That is a zero and not the letter OH.

Once these settings are in there, you should have full connectivity to your device via USB to the serial interface on the device! Exit minicom and re-open it with the settings from before. To do this, you'll want to do is either run

Code: [Select]
sudo minicom savefilenameor
Code: [Select]
sudo minicomif you saved it as your default.

Once you have re-opened minicom, you should be able to test anything that you type at all and it will show on the screen directly as you type it. What this means is it is getting sent via minicom to the device, then going into the device and getting output by the device as well and then getting printed back on the screen! 


I hope that this has been helpful to someone that needs a good starting point with the TUMPA and if anyone is interested, I can post more of these once I learn small tips and tricks that might help along the way. I look forward to lots of fun with the TUMPA. And minicom seems to be a very handy program for interfacing with it.


I wrote this on a forum that was for the TIAO device but decided that if I write a blog post about this device, it will probably bode well for the general public rather than finding it buried somewhere deep in a forum. Who know's how long those are saved and such! SO I hope this has been informative for anyone and if you have any questions, I plan on playing with my TUMPA more as time goes on so I will try to answer any questions you might have! Thank you guys! I'll try to share more when I can!

PS - Maybe next time, if I get a bit of free time, I'll add pictures for this post to help in the learning process. Some people are visual learners. I try to cover all walks of life.

-Mitch

Thursday, February 6, 2014

Cat!

     Wow it has been a while... It's going to be a fairly short update too. I plan on doing this one more often now that things have calmed down just a tad but, for now I will share with you the thing I most recently learned!

CAT!

     Cat is an interesting item for sure! If you just use it as it is... [cat file.txt] will show you the contents of the text file in your CLI. Or if you wanted to, you could cat those contents into a different file. So let's say that you were writing a code, and you needed the output of a file put into a variable or something, you could do it with cat. You can also do that just in your everyday if you wanted to make a HUGE text file from 37 different text files. You would just say [cat file.txt > big_text.txt] and then it would take the contents of file.txt and put it into big_text.txt. Handy! Then you just do that 37 times and you are set!

     But wait, there's more! You can even shorten that! I believe you could do that with something like this [cat file.txt file2.txt ..insert others here.. file37.txt > big_text.txt]. That's not super handy for something like 9,392 files but.... For a few it sure is! I think you could also make a clean folder and copy all of your text files to the folder and ONLY have the text files you want in there and simply do [cat *.txt > big_text.txt] and you would catch all and then put them into the big_text file! So handy!

     Another useful implementation of this process is for "part" iso files... Let's say you get something.iso_part1 and then something.iso_part2... Well that's just silly! Who would do that? People that can't host large files. The WORST kind of people... That's ok. We can solve this problem without giving them an earful. It's relatively easy also! Basically... You take the first file, second file, and then output it to 'complete.iso' and it will do it! As an example [cat /path/to/first.iso_part1 /path/to/second.iso_part2 > completed.iso]... Then you should have a combined file that is the complete iso! How handy is that! "Very" is the answer you were looking for.

     And that is a very useful thing that you can do with the [cat] command. It might not be something you use every day but it can definitely save you from copying and pasting 2,000 times.