WASHINGTON (AP) _ Telephone companies are declaring war on the thousands of college students, professionals, and even prisoners who get into the telephone network illegally and ring up a half billion dollars in unpaid calls a year.

Companies are changing the software as well as the hardware in their networks to try to block the calls, and they are offering amnesty programs on college campuses for students to fess up and pay up.

They also are working with federal authorities to prosecute call-sell operators who are using stolen authorization codes and electronic devices to break into the network and sell calls to all parts of the world at drastically discounted prices.

''We look at it as a major problem, and it's definitely well worth going after this half a billion dollars,'' said Rami Abuhamdeh, executive director of the industry-sponsored Communications Fraud Control Association. ''In any industry, if you don't do anything about it, it's only going to get worse.''

Computer-literate college students are among the biggest offenders and their campuses are breeding grounds for large-scale theft. Authorization codes get passed around quickly, allowing students to phone home for free, telephone company security officials say.

''That's something we're going to have to deal with because college students have inquisitive minds and they like to do things like challenge the network,'' said Neal Norman, district security manager for American Telephone & Telegraph Co.

MCI Communications Corp. officials say they recently pursuaded 1,000 students at North Texas State University in Denton, Texas, to turn themselves in and pay about $100,000 for the illegal calls they made.

At American University in Washington, D.C., 400 students turned themselves in and are being billed for about $25,000 so far, MCI spokesman John Houser said.

Computer hackers - including doctors, lawyers and some housewives - who search computer files for authorization codes are another problem, but Abuhamdeh says their heaviest damage is in selling the codes or posting them on electronic billboards. The hackers themselves usually don't make as many calls as other groups, including prisoners, he said.

''Prisoners have a lot of time on their hands and they're very innovative. And unfortunately in a lot of places, they have access to phones continually,'' AT&T's Norman said.

In one case, Norman said, a prisoner called a hospital, identified himself as a doctor and asked to be connected to another number in the hospital. When that number answered, he asked to be switched to the hospital operator, whom he asked to connect him to an outside line for a long-distance call.

Companies are using sophisticated computer technology to identify patterns of illegal calling, which are often traced to operations run by ''call sellers.''

''They make $2,000 a week selling calls, and that's tax-free,'' said Martin Preede, a special agent for corporate security at New York Telephone Co. But he warned that phone companies and federal authorities are actively tracking down such operations and prosecuting.

Preede helped authorities gather evidence against Raphael Rodriguez, who was convicted by a U.S. District Court jury in Manhattan earlier this month for using unauthorized devices to break into the phone network.

His was the first such case to go to trial in Manhattan - all the others have plea bargained down to suspended sentences - where he was sentenced to 20 months in jail and five years probation and was ordered to pay restitution of $20,000, said Assistant U.S. Attorney Carl Loewenson Jr.

''His operation was more sophisticated than most,'' Loewenson said. ''Most of the buyers usually have to go to the apartment of the seller to make the call, but he had three-way calling'' so buyers could talk from home.

Most of the calls he made were to the Dominican Republic, where for an hour-long call worth $85 he was charging $15, the prosecutor said.

Call sellers get their authorization codes from a variety of sources, including computer hackers, but also from people who simply watch callers punch their codes into telephones at airports and bus stations.

''They even use binoculars to read the numbers,'' Abuhamdeh said. ''They're very skilled at reading numbers.''

US Sprint Communications Co., the third-largest long-distance company, has doubled the size of its fraud-detection staff to more than 100 since January and has improved its computer programs to watch for sudden increases in telephone use and trace the original caller.

All long-distance companies are suffering, but few will discuss their losses. Last week, in one of the few public acknowledgements of specific losses, Sprint reduced its first-quarter revenue by $19 million to offset uncollectible bills in the second half of 1986.

Abuhamdeh estimates the industry loses about 1 percent, or about $500 million, to fraud a year, but he says ''it's tough to assess losses because it's a touchy topic with companies.''

Long-distance leader AT&T and No. 2 MCI both declined to specify their losses to fraud. Norman said at the end of 1983, just before the Bell System break-up when the number of long-distance companies swelled, AT&T's annual fraud losses were about $150 million., Norman said.

AT&T says its fraud problem has decreased, but security officials in the industry say the overall increase in the industry is due to the proliferation of long-distance companies opening new opportunities for all kinds of telephone fraud.

''Everytime you find an answer for one area, another problem crops up. It's a continual battle,'' said AT&T's security chief.