Pages

Saturday, May 16, 2015

GNU Radio and HackRF One on Debian 8

I started with Kali Linux and switched back to Debian after spending a weekend dealing with USB driver issues. Then I realized that I didn't take any notes and had to google everything a second time.

So this time, here are my notes in case I end up doing this a third time.


First the preliminary stuff:

Get Git installed

apt-core install git-core

Next update the basic Build support packages:


apt-get install build-essential
apt-get install python2.7-dev
apt-get install cmake
apt-get build-dep libcppunit-dev
apt-get install python-cheetah
apt-get install libboost-all-dev

Don't Forget to run apt-get update

Then finally its build time!

mkdir build
cd build
cmake ../
make && make test

sudo make install



Multiple Monitor Support on Debian 8

I started with the graphical display tool and from there I was able to switch the primary and secondary monitor; however, to switch the right/left placement would just hang the system.
After rebooting, it was back to the good old terminal mode (So much for Linux Graphical interfaces)


xrandr worked great:

root@darkside:/home/williamk# xrandr --output DVI-D-1 --right-of DVI-I-1

A quick flicker and positions were switched.



Wednesday, August 27, 2014

How to find the definition of a User-Defined Table Type


SELECT c.name, st.name, c.is_nullable, c.max_length, c.precision, c.scale
       FROM sys.columns c INNER JOIN sys.table_types tt
                          ON c.object_id = tt.type_table_object_id
                          INNER JOIN sys.types st
                          ON c.system_type_id = st.system_type_id
       WHERE tt.name = '{Insert Type Name Here}';


Friday, January 31, 2014

Adding a not null column to an Existing Table


ALTER TABLE dbo.My_Table
    ADD New_Column VARCHAR(100) NOT NULL
        CONSTRAINT DF_My_Table_1 DEFAULT 'Unspecified' WITH VALUES;



Wednesday, March 7, 2012

Prevent a host from connecting to SQL Server


Normally I would block a network device using the windows firewall; however, when that option is not available you can can still block the device from SQL server. This SQL Script will create a DDL trigger that will reject connections attempts from a specific network client based on the host name.


CREATE TRIGGER tr_Reject_Connection ON ALL SERVER
    WITH EXECUTE AS self
    FOR LOGON
AS
BEGIN
    IF 'Client Host Name' = HOSTNAME()
        BEGIN
            ROLLBACK;
        END
END;
GO


ENABLE TRIGGER tr_Reject_Connection ON ALL SERVER
GO

To Reject a client based on the IP address, change the IF statement to read:


     IF 'Client IP Address' = ConnectionProperty('local_net_address')


In addition, these events are automatically logged in the SQL Log file, for example:



       Date            Source                    Message
-------------------  ----------  ------------------------------------------------------------------------------------------------
03/07/2012 16:08:37 Logon    Logon failed for login 'ADOMAIN\TestUser' due to trigger execution. [CLIENT: 192.168.78.190]
03/07/2012 16:08:37     Logon    Error: 17892  Severity: 20   State: 1.
03/07/2012 16:08:37     spid104  The transaction ended in the trigger. The batch has been aborted.
03/07/2012 16:08:37     spid104  Error: 3609   Severity: 16   State: 2.



Thursday, March 1, 2012

MS SQL: Hiding sys and INFORMATION_SCHEMA Objects


As of SQL 2005, Microsoft created a super-secret hidden database called mssqlsystemresource.  The master database is now really just a front for this database.  So in reality, these objects do not exist in master and as a user, you cannot access the mssqlsystemresource database.

However, there is a work around.  First a disclaimer, middleware such as ODBC rely on access to sub set of these tables, so once you restrict them from the user, you are also restricting them from ODBC (and other middleware).

Here is a simple example:

USE master
CREATE LOGIN SecuredAccount WITH PASSWORD=N'Password123', DEFAULT_DATABASE=Junk,DEFAULT_LANGUAGE=us_english, CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO

USE Junk
CREATE USER SecuredAccount FOR LOGIN SecuredAccount
GO
-- Restrict the user from any DDL
EXEC sp_addrolemember N'db_datareader', N'SecuredAccount'
EXEC sp_addrolemember N'db_datawriter', N'SecuredAccount'
GO
--
-- ----------------------+
USE master
CREATE USER SecuredAccount FOR LOGIN SecuredAccount
GO
-- Blocks INFORMATION_SCHEMA Objects
EXEC sp_addrolemember N'db_denydatawriter', N'SecuredAccount'
GO
EXEC sp_addrolemember N'db_denydatareader', N'SecuredAccount'
GO
--  Each individual object in the sys schema needs to be restricted
--  But this can be scripted, so its not too bad.
USE Junk
-- Tables and views can be restricted at the local database
DENY SELECT ON sys.all_objects TO SecuredAccountGO
USE master
-- Stored Procedures need to be blocked in the master database
DENY EXECUTE ON sys.sp_tables TO SecuredAccount
GO
And as a test, created a simple table called and inserted four rows, and then log in as SecuredAccount and execute:
SELECT * FROM Test;
SELECT * FROM INFORMATION_SCHEMA.Tables;
SELECT * FROM sys.all_objects;
EXECUTE sys.sp_tables
The results should be:
-- The first select returns the 4 rows correctly
(4 row(s) affected)
-- Everything else fails. Note the database name in the error messages.
Msg 229, Level 14, State 5, Line 2
The SELECT permission was denied on the object 'TABLES', database 'mssqlsystemresource', schema 'INFORMATION_SCHEMA'.
Msg 229, Level 14, State 5, Line 3
The SELECT permission was denied on the object 'all_objects', database 'mssqlsystemresource', schema 'sys'.
Msg 229, Level 14, State 5, Procedure sp_tables, Line 1
The EXECUTE permission was denied on the object 'sp_tables', database 'mssqlsystemresource', schema 'sys'.