I'm from Iran but I live in Hungary now, I have resident permit for students for 1 year. I want to go to Germany and stay there more than 3 months, but I'm not sure about regulations. Is it possible? Will I get in trouble for rent a house or other things?
Your Hungarian residence permit allows you to visit other Schengen states as if you had a C visa, i.e. 90 days out of every 180 days. To stay any longer, you would need a German D visa.
Renting a flat or house should be possible, but doing so will draw attention to the fact that you're living at least part of the time in Germany and not in Hungary. (As a resident in Germany, you have to register all your residences with the municipal offices and you have to designate one of them as your primary residence for tax purposes, etc.) This could bring extra scrutiny to the question if you're following the 90/180 rule.