Well from what I can gather the knights templar went and found out about the gnostics who learned about satanism from the kaballah a book on Jewish mysticism. The templars then ran away to Scotland where they would found the first lodge on the 13th century in Kilwinning. Rosicrucianism would follow in the years between the 13th and 18th centuries until finally popping out more publicly as freemasonry, the square and compass are found in a lot more places than you think and predate actual freemasonry. The kaballah is basically just magic and shiet derived from the Egyptian pharaoh in the time of noah, who in turn received it from the original mystery cults of Babylon.