I would not waste my money on an engine from ebay, you have no idea what the history of the engine is. If you do get a mechanic to install it and there are any problems you will be on the hook for paying as the mechanic did not supply the engine. Talk to your local mechanic and get a price from them. They know who to get a trusted engine from and could provide a warranty on their work and the engine. In the US you are looking at $2,000-$3,000 USD to have a used engine installed. Not sure what gasket you are asking about. The head gasket is not typically replaced.
You must first ask YOUR mechanic, or more than one, for their prices. WE can not possibly know.
BUT . . a USED engine needs some additional prep work too. Especially if you have an extremely narrow window of returnability for your purchase.
Have your mechinic check things like the condition of its old oil and compression immediately before the seller can claim you did something to it.
Plus he will put in new spark plugs , filters and fluid changes.
I’d say you are looking at 10 hours of labor at a minimum, so multiply the hourly rate in your locale by 10 at least.
If you buy the motor and take it and the car to a shop for installation you are playing in a lot of “unknown” territory. This will make it impossible for the shop to give you a firm quote for the job. A very general estimate is the best you will get and costs can go way up if something unexpected shows up.
Also, the new motor has to be compatible with all the pollution controls and electronic components. This makes getting the right motor important. I think it is best for the shop to source the replacement motor. That will reduce problems and make the price of the job more reliable.
Are you sure that the engine has a major mechanical problem?
A rumbling noise could come from one of the accessory pulleys or the serpentine belt tensioner.
I just last week repaired a 2002 Corolla engine that a professional mechanic (I use both words loosely) insisted needed replacing. Runs like new now. The owner is thrilled. I think it was the repair of the primary wire to the #3 coil that did it . The new plugs helped too, I’m sure. Threw in a new PCV valve to reduce oil usage… the old original one was gumped up.
Around $400 for a new engine, parts cost, that’s a very good deal. This is one of the advantages of buying a Corolla, excellent availability of frugally-priced parts from wrecks.
Whether that particular engine will work well after installed in your car, no idea. Most suggestions here on engine replacement is to secure a guarantee from the installer/& engine vendor that the engine actually works correctly, or they will replace it with one that does gratis. If it is from a wrecked Corolla and the wreck didn’t involve the engine, it will probably work fine. Do you know how many miles is on that engine?
I think @UncleTurbo 's estimate of 10 hours to remove and replace the engine is a good estimate provided the replacement engine has all the needed parts installed on it already. In other words the engine install is a turn-key operation. If the shop has to move parts from your current engine to the replacement, then diagnose why they don’t work, add as much as 4-6 hours. If you have AC, add another hour to that.
In my part of the USA hourly cost is around $100 per hour, so you’d be looking at maybe $1500 labor plus $400 for the engine, around $1900. That’s a pretty good deal if the engine works. I don’t think there will be a guarantee at that price though. That’s the gambling man’s price.
Has a real mechanic looked at your engine and determined it actually needs to be replaced? What exactly has failed ? Corolla engines seldom fail at 65K miles unless they have been severely abused or run out of oil…