Shanty towns are aptly named. They are made up of shanties.
: A small, crudely built shack.
Oxford offers "shack", "hut", and "cabin" as synonyms, among others. These three most closely represent a dwelling, though.
Shanty, shack, hut, or hovel are all correct words for such a dwelling.
There are other terms that might be more meaningful and descriptive in specific contexts of locale or time. A well-known historical example, pertains specifically to a shanty. These shanties were collectively referred to as Hooverville communities during the Great Depression in the United States in the 1930s. They arose spontaneously in response to extreme deprivation and poverty. They were present throughout the USA, and even erected on the front lawn of the White House in Washington D.C. by 50,000 homeless veterans during the first year of President Roosevelt's administration.
Shanties were clearly built "with random materials" as described in the title of the question:
Hooverville shanties were constructed of cardboard, tar paper, glass, lumber, tin and whatever other materials people could salvage. Unemployed masons used cast-off stone and bricks and in some cases built structures that stood 20 feet high.
Most shanties, however, were distinctly less glamorous: Cardboard-box homes did not last long, and most dwellings were in a constant state of being rebuilt. Some homes were not buildings at all, but deep holes dug in the ground with makeshift roofs laid over them to keep out inclement weather. Some of the homeless found shelter inside empty conduits and water mains.
Although the question was tagged as a single word request, another term for such a house is a makeshift dwelling.
A makeshift dwelling.
makeshift adjective. uk /ˈmeɪk.ʃɪft/ us /ˈmeɪk.ʃɪft/ › temporary and of low quality, but used because of a sudden need: Thousands of refugees are living in makeshift camps. Temporary.