another technical blog...technically

Saturday, June 20, 2015

Onion Pi: Set up as a Wifi-to-Wifi Tor middlebox

Some weeks ago i bought a Raspberry Pi 2 in order to replace my old Raspberry Pi as media center...
So i had some free time and unused spare wifi connectors and i decided to create a tor access point using this guides.
https://learn.adafruit.com/onion-pi/overview  
https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview
This access point is completely useless in my home, but i was curious about it, outside it was rainy and you know, cuorisity is the cure fore boredom.
Those guides are quite self-explaining, but what if you want to set up a Wi-Fi to Wi-Fi middlebox?
The guide does not provides so muchi infos about it.
Let's assume:
eth0: adapter you connect to the main router wlan0: adapter you want to connect to the main router wlan1: adapter you want to use as access point
what you have to do using iptables is:
Create a network translation between the adapter wlan1 and the adapter wlan0 (in my case also hostap uses as interface wlan1)
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
Set up new iptables rules, redirecting also wlan0 traffic to torrc TransPort 9040 (adding also the well knows exceptions)
sudo iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22
sudo iptables -t nat -D PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -D PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040
That's all folks.
Share:

SharePoint 2013 Azure farm accessible from outside part 2: what about friendly URLs

Have you read this? SharePoint 2013 Azure farm accessible from outside
I discovered it doesn't work for friendly urls, it shows hyperlinks targeting site collection, so it's not possible to reach other pages. Moreover you'll get this error if you only create a outbuond rule for URL rewriting because of the gzip compression.
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip").
What you have to do is something like this:
  • Introduce a outbound rule which rewritest some links
  • Introduce rewrite rules for gzip compression
The example below assumes:
  • Local site collection is: http://sitecollection.example.cloud
  • Public azure url is: http://publicsite.example.azure

    
        
            
                
                    
                    
                        
                        
                    
                    
                
            

            
                
                    
                    
                
                
                    
                    
                

                
                    
                        
                    
                    
                        
                    
                
                    
        
    

And that's all... for now!
Share:

Monday, June 8, 2015

Targeting contents using XRANK in SP2013 problem

Lately i had to create a content priority/targeting system in SharePoint 2013, using search capabilities in a public context (so no target audience available).
What you'll find below it's a targeting system based on managed metadata content tagging and dinamically generated queries using XRANK directives.
Let's think about a enterprise model with a hierarchy like this
  • Channel 1 (00000000-0000-0000-0000-000000000100)
    • Network 1 (00000000-0000-0000-0000-000000000110)
      • Agent 1 (00000000-0000-0000-0000-000000000111)
      • Agent 2 (00000000-0000-0000-0000-000000000112)
    • Network 2 (00000000-0000-0000-0000-000000000120)
    • ...
    • Network n (...)
  • Channel 2 (00000000-0000-0000-0000-000000000200)
  • ...
  • Channel n (...)
This could be represented as a hierarchical term set in Managed Metadata Service Application.
Now, let's assume we have these contents:
  • Page A, tagged with "Channel 1"
  • Page B, tagged with "Network 1"
  • Page C, tagged With "Agent 1"
Following this article http://techmikael.blogspot.it/2014/03/s15e01-kql-basics.html we can target contents using Search.
For example, if i am "Agent 1" and i want to obtain contents in this order
  1. Page C
  2. Page B
  3. Page A
i can use a query like this
(((owstaxIdTargeting:"GP0|#00000000-0000-0000-0000-000000000100" XRANK(cb=1))
owstaxIdTargeting:"GP0|#00000000-0000-0000-0000-000000000110" XRANK(cb=10))
owstaxIdTargeting:"GP0|#00000000-0000-0000-0000-000000000111" XRANK(cb=100))


Basically, i'm boosting contents created for "Agent 1", then contents for "Network 1", then "Channel 1".
Great? No. This method apparently works.
In this query i used XRANK, which boost the rank score... boost means SharePoint assign a score using ranking models you can boost manually using XRANK query directive.
This also means that rank scores could be scrambled by a lot of rank model rules, take a look to this articles:
This leads me to think i can create a "Fake ranking model" for those queries, useful only for this content targeting technique.
This model basically assigns a 0 score to all contents and it simply does NOTHING, so only XRANK values will be considered.

 
  
   
    0
   
   
    0
   
  
  
  
 

You can install this rank model on SharePoint farm and use it in your search based query (programmatically and/or in content search query web part).
Share:

SharePoint 2013 Azure farm accessible from outside

I gave you the possibility to create a SharePoint 2013 farm from scratch with ASPM... don't you know what it is? You can download it here
So, let's assume you have a site collection (http://sitecollection.example.cloud) on this SharePoint 2013 farm e you want to make it accessible to your customer, manager and so on...
Open IIS Manager and head to Default Web Site, then URL Rewrite (if you don't have this option on your IIS please downlad URL Rewrite module from Web Platform Installer).

Then, create a new blank rule

like this

And that's all.
I noticed you will have some problems with users adding, so it's possible you can experience some problems with other features.
Maybe further settings could be necessary.

Thursday, June 4, 2015

Updating term set in SP2013

First of all, this is not something i discovered on my own, i just read it somewhere in the web and I never found the original post again, maybe because it was written in german (credits to the original author), so I decided to write this useful trick in english in order to help more people to accomplish the same task: updating a termset from code behind.
Let’s assume you need to do this from an application page, you need to use the SPSecurity and RunWithElevatedPrivileges as usual.
SPSecurity.RunWithElevatedPrivileges(() =>
{
 using (SPSite elevatedSite = new SPSite(site.ID, site.Zone))
 {
  TaxonomySession taxonomySession = new TaxonomySession(elevatedSite);
  //Do here the update work
 }
});
Ok! This code simply doesn’t work: this is due to the fact you have to switch the context to the service account one like this.
SPSecurity.RunWithElevatedPrivileges(() =>
{
 using (SPSite elevatedSite = new SPSite(site.ID, site.Zone))
 {
  HttpContext oldContext = HttpContext.Current;

  try
  {
   HttpContext.Current = null;
   TaxonomySession taxonomySession = new TaxonomySession(elevatedSite);

   //Do here the update work
  }
  finally
  {
   HttpContext.Current = oldContext;
  }
 }
});
le jeux sont fait
Share:

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?