четвъртък, 21 юни 2018 г.

Setting Alsa default device to HDMI

Configuration required in /etc/asound.conf - to change default audio PCM to HDMI
*# cat /etc/asound.conf
pcm.!default {
type plug
slave.pcm "hdmi:0,0"
}
* (this is the same "hdmi device" that can be found in Kodi's guisettings.xml, and in "aplay -L")
* alsactl --force restore #loads the new config; no reboot required
* to test if it was taken as 'default':
* speaker-test -c 2 -r 48000
* If this works, librespot is going to work as well
* Note that the output of aplay -L still shows "ALC892 Analog" as the default audio device - this is irrelevant

вторник, 22 декември 2015 г.

EdgeSwitch import/export config

(UBNT EdgeSwitch) >enable

(UBNT EdgeSwitch) #ip ssh server enable

(UBNT EdgeSwitch) #copy system:running-config nvram:factory-defaults     

This operation may take a few minutes.
Management interfaces will not be available during this time.

Are you sure you want to save? (y/n) y
#
Config file 'factory-defaults' created successfully .

Configuration Saved!

(UBNT EdgeSwitch) #clear config

At this point even after clear config we will have ssh enabled because its set in factory-defaults and 'clear config' reverts to it.

Get current config.

(UBNT EdgeSwitch) #copy system:running-config tftp://192.168.1.66/config1

Edit it by your desire. Add whatever configuration you need.

(UBNT EdgeSwitch) #copy tftp://192.168.1.66/config1 nvram:script config1.scr


(UBNT EdgeSwitch) #script apply config1.scr

If we need to change something again do 'clear config' first. Then download new config and apply it.

To transfer config across reboots:

(UBNT EdgeSwitch) #copy system:running-config nvram:startup-config

четвъртък, 19 ноември 2015 г.

Solaris Bridge/Switch

The idea is that we need to use 4 x 10Gbe interfaces on a Solaris box for switch for 4 hypervisors and at the same time have connection from the hypervisors to the storage (the same 4 x 10 Gbe box)

root@mrsas:~# dladm create-bridge -l ixgbe0 -l ixgbe1  -l ixgbe2 -l ixgbe3 storage
root@mrsas:~# dladm show-bridge
BRIDGE      PROTECT ADDRESS            PRIORITY DESROOT
storage     stp     32768/0:25:90:f9:6b:2e 32768 32768/0:25:90:f9:6b:2e
root@mrsas:~# dladm show-link
LINK        CLASS     MTU    STATE    BRIDGE     OVER
igb0        phys      1500   up       --         --
igb1        phys      1500   unknown  --         --
ixgbe0      phys      1500   up       storage    --
ixgbe1      phys      1500   up       storage    --
ixgbe2      phys      1500   up       storage    --
ixgbe3      phys      1500   up       storage    --
storage0    bridge    1500   up       --         ixgbe0 ixgbe1 ixgbe2 ixgbe3
root@mrsas:~#



>> I tried to setup a etherstub and a vnic. I then tried to setup a bridge between that and the physical interface, as follows:
>>
>> LINK        CLASS     MTU    STATE    BRIDGE     OVER
>> igb0        phys      1500   up       zbridge    --
>> igb1        phys      1500   up       --         --
>> workswitch0 etherstub 1500   unknown  zbridge    --
>> work0       vnic      1500   unknown  --         workswitch0
>> zbridge0    bridge    1500   up       --         workswitch0 igb0
>
> Perhaps a dumb question here, but why would you do that?  The whole
> point of an etherstub object is that it's not connected to the outside
> world.  And if you want a connection to the outside world, why not just
> create the vnic on top of a real link?
>
> That aside, I think you might get further using 'dladm create-simnet'
> rather than an etherstub.  A simnet is a simulated Ethernet interface.
>
> As for the "STATE unknown" bit, I believe that's because etherstubs
> don't have physical links and thus don't have physical link status.
> It's probably harmless.

root@mrsas:~# dladm create-simnet nic0
root@mrsas:~# dladm show-link
LINK        CLASS     MTU    STATE    BRIDGE     OVER
igb0        phys      1500   up       --         --
igb1        phys      1500   unknown  --         --
ixgbe0      phys      1500   up       storage    --
ixgbe1      phys      1500   up       storage    --
ixgbe2      phys      1500   up       storage    --
ixgbe3      phys      1500   up       storage    --
storage0    bridge    1500   up       --         ixgbe0 ixgbe1 ixgbe2 ixgbe3
nic0        simnet    1500   up       --         --

root@mrsas:~# ipadm create-if nic0
root@mrsas:~# ipadm create-addr -T static -a 172.16.20.1/24 nic0/v4
root@mrsas:~# ipadm show-if
IFNAME     STATE    CURRENT      PERSISTENT
lo0        ok       -m-v------46 ---
igb0       ok       bm--------46 -46
ixgbe1     down     bm--------46 -46
ixgbe2     ok       bm--------46 -46
ixgbe3     down     bm--------46 -46
nic0       ok       bm--------46 -46

root@mrsas:~# dladm add-bridge -l nic0 storage
root@mrsas:~# dladm show-link
LINK        CLASS     MTU    STATE    BRIDGE     OVER
igb0        phys      1500   up       --         --
igb1        phys      1500   unknown  --         --
ixgbe0      phys      1500   up       storage    --
ixgbe1      phys      1500   up       storage    --
ixgbe2      phys      1500   up       storage    --
ixgbe3      phys      1500   up       storage    --
storage0    bridge    1500   up       --         ixgbe0 ixgbe1 ixgbe2 ixgbe3 nic0
nic0        simnet    1500   up       --         --

Links:
http://www.c0t0d0s0.org/archives/7424-Simulating-the-cloud-a-practical-example..html

вторник, 16 юни 2015 г.

Close frozen ssh session

 
[enter]~. First press the Enter key, then tilde, and then add a dot and your ssh session will be closed and you can continue your work in back in freed terminal.

неделя, 17 май 2015 г.

USBCCID Dissection & B-Trust Reader/Writer ACR38T

Започвам едно разследване за което е силно вероятно да нямам никакво време да продължа, но това няма да ми попречи да документирам днешните си занимaния.

Кратка предистория:
Имам КЕП (Квалифициран Електронен Подпис) издаден от B-Trust. Като всяка институция в нашата родина тези хора са безкрайно некохерентни в използвана терминология и скачат от преводен термин на български в някакви заемки от чужд език които дори според производителя на устройството не са такива. Пример 'SO PIN' и 'Unblock PIN' са едно и също нещо според тях а на родната публика това по-скоро е известно като 'PUK'.
Понеже в случя става дума за четене на информация от SIM карта на мен ми се струва че употребата на PUK е далеч по-добра или е трябвало поне да се придъжат към терминологията на производителя 'SO PIN'. Но това е друга бира. По темата:

Рекох да си сменям пиновете на устройството и понеже съм много чевръст в пръстите успях да си сменя потребителския пас (PIN - ако се придържаме към телефонните термини) и в опит да си сменя PUK видях как attempts left полето се смалява от 3 към 0 и ме известява че видиш ли съм си блокирал картата. Добре обаче това изобщо не е вярно тъй като устройството работи, а с въведен правилен PIN даже подписва официални документи и банкови плащания.

И почвам да си мисля - SIM картата е носител на информация. Като такъв от него може да се чете. Добре обаче явно и без аутентикация от какъвто и да е тип може и да се пише (може и да е частен случай, но писането в attempts полето е възможно). Е щом е възможно аз защо не зема да си запиша там 999 и да си тествам с каквито там пароли си мисля че съм сложил.

Поразрових в нета и се оказва че тия хора в Белгия ги ползват тези устройства и за други неща и един младеж си е написал дъмпвачка:

https://github.com/xofc/Beid2html

Кода е толкова лалав че все едно аз съм го писал което не е задължително лошо понеже му разбирам какво прави. Човека ползва libusb-1.0

В неговият случай не е писано за същото устройство и съоетвено се налага да се смени usb id-то от хардкоднатото при него 1a44:0870 на 072f:90cc


След тази смяна връзката с устройството окача и той се впуска да му викне един статус:


if (libusb_bulk_transfer(udevp, 0x01, bufout, sizeof(bufout), &n, 1000) < 0)
  {
  fprintf(stderr, "bulk-out failed\n");
  perror("PC_to_RDR_GetSlotStatus");
  return;
  }

Хубаво прави ама много бързо се отказва. След като снифнах с wireshark как си говорят купешкия app и девайса се оказва, че традицията повелява не един, не два а точно 5 пъти да му искаш статус а то да се прави че не разбира. И чак след петия път да му пуснеш един пауър он:



И след пауър онът девайса вече съвсем културно връща  EJCOPv241 за Chip Operating System.

И почват да си говорят с дата блоци. Но кога ще ги разнищя те какви са...
to be continued (or not).

вторник, 25 ноември 2014 г.

Linux Bridge to act like hub

If in need to make a linux bridge very stupid and act like hub:

brctl setageing <bridgename> 0 




This command tells Linux to forget every MAC address that it sees on
the bridge, making it act as a hub.



Lets say you have a vmbr0 with eth0 and tap0 in it and have a VM started with attached tap0 (or you choose it as vmbr0). If you link eth0 to your switch's mirroring port you wont RX a great deal of the traffic because usually linux bridge acts as switch and does not recognize the VM as endpoint for the traffic.

Above command will give you a way to have a VM that listens a mirrored port (so NIDS could be on VM).

You are welcome!

сряда, 3 септември 2014 г.

Какво правим когато забравим да пуснем програмата в screen?

   reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.

Source
Info



neercs is a work-in-progress libcaca project.
Like GNU screen, it allows you to detach a session from a terminal, but provides unique features:
  • Grabbing a process that you forgot to start inside neercs
  • Great screensaver
  • 3D rotating cube to switch between full screen terms
  • Real time thumbnails of your shells
  • Special effects when closing a window
  • Various window layouts...
neercs was written by Sam Hocevar, Jean-Yves Lamoureux and Pascal Terjan. It is free software, and can be used, modified and distributed under the terms of the Do What The Fuck You Want To Public License.