Firstly:
Prohibition on helping with gambling
It is haraam to help with gambling such as lotteries, and that includes working on configuring routers that the company uses, because Allah, may He be exalted, says (interpretation of the meaning):
{And cooperate in righteousness and piety, but do not cooperate in sin and transgression. And fear Allah; indeed, Allah is severe in penalty} [al-Maa’idah 5:2].
And the Prophet (blessings and peace of Allah be upon him) said: “Whoever calls people to misguidance will have a burden of sin like that of those who follow him, without that detracting from their burdens in the slightest.” Narrated by Muslim in his Saheeh (4831).
If you are able to avoid this work, and continue with your other responsibilities, there is nothing wrong with you staying with that company. But if you cannot avoid what is haraam, then you must leave this job, and whoever gives up something for the sake of Allah, Allah will compensate him with something better.
Secondly:
Money earned by helping with the lottery
With regard to the money that you earned when you were unaware of the prohibition on this work, or when you followed a fatwa issued by one who granted you a concession to remain in that job until you find another job, there is nothing wrong with you making use of it, even if some of it is in your possession, because Allah, may He be exalted, says with regard to riba (usury, interest), which is one of the worst of prohibited things (interpretation of the meaning):
{Allah has permitted trade and has forbidden interest. So whoever has received an admonition from his Lord and desists may have what is past} [al-Baqarah 2:275].
Shaykh al-‘Uthaymeen (may Allah have mercy on him) said: If he did not know that this is haraam, he may keep what he received and he does not have to do anything. Or if he was deceived by a fatwa from a scholar saying that it was not haraam, he does not have to give anything, because Allah, may He be exalted, says (interpretation of the meaning):
{Allah has permitted trade and has forbidden interest. So whoever has received an admonition from his Lord and desists may have what is past} [al-Baqarah 2:275]".(Al-Liqa’ ash-Shahri 67/19).
As for the money that you received after finding out that it is haraam to remain in this job: regarding what you spend of it, you do not have to do anything regarding it except to repent. Regarding what remains with you of it, you must get rid of the haraam portion of it, by giving it to the poor and the like.
If your permissible work takes up half of the day or half of the month, and your unlawful work takes up the other half, then what is prohibited is half of your salary.
But if you need the money that you have, meaning that if you give it in charity, you will not be able to spend on your family’s maintenance, then there is no blame on you if you make use of it. So you should take as much of it as you need, and give the rest in charity.
For more information, please see the answers to questions no. 103918 and 78289 .
We ask Allah to provide for you from His bounty, and to make you independent of means through that which is halaal and good.
And Allah knows best.